Given three function parameters p1, p2, p3, rotate the values to the right. Rotate means to shift each item to the item on the right, with the rightmost item rotating around to become the leftmost item. If initial values are 2 4 6, final values are 6 2 4. Hints:

Required:
Declare the function's three parameters as reference type. Function return type is void.

Respuesta :

Answer:

#include <iostream>

using namespace std;

void RotateRight3( int& p1, int& p2, int& p3)   {

     int = tmp;

     tmp = p3;    

     p3 = p2;        

     p2 = p1;      

     p1 = tmp;    

}

int main()   {

     int n1, n2, n3;

     cin >> n1;      

     cin >> n2;

     cin >> n3;

     RotateRight3(n1, n2, n3);

           cout << n1 << " " << n2 << " " << n3 << end1;

     return 0;

}

Answer:

void RotateRight3( int& p1, int& p2, int& p3)   {

    int = tmp;

    tmp = p3;    

    p3 = p2;        

    p2 = p1;      

    p1 = tmp;    

}