In: Computer Science
Let a , b , c be three integer numbers. Write a C++ program with a functions
void rotate1(int* a,int* b,int* c)
void rotate2(int& a,int& b,int& c)
such that a -> b , b -> c and c -> a. Thus we use two different approaches (pointers in rotate1 and references in rotate2).
#include <iostream>
using namespace std;
void rotate1(int *a, int *b, int *c) {
    int temp = *a;
    *a = *c;
    *c = *b;
    *b = temp;
}
void rotate2(int &a, int &b, int &c) {
    int temp = a;
    a = c;
    c = b;
    b = temp;
}
int main() {
    int a = 2, b = 7, c= 3;
    cout << "Before, a = " << a << ", b = " << b << " and c = " << c << endl;
    rotate1(&a, &b, &c);
    cout << "After, a = " << a << ", b = " << b << " and c = " << c  << endl;
    cout << "Before, a = " << a << ", b = " << b << " and c = " << c  << endl;
    rotate2(a, b, c);
    cout << "After, a = " << a << ", b = " << b << " and c = " << c  << endl;
    return 0;
}
