Answer to Question #281295 in C++ for haseeb

Question #281295

Given three variables x, y, z write a function to circularly shift their values to right. In

shift y = 5, z = 8 and x = 10. Call the function with variables a, b, c to circularly shift

other words if x = 5, y = 8, z = 10 after circular shift y = 5, z = 8, x =10 after circular

values.


1
Expert's answer
2021-12-20T10:01:46-0500
#include <stdio.h>

void shift(int* a, int* b, int* c)
{
    int tmp;
    tmp = *c;
    *c = *b;
    *b = *a;
    *a = tmp;
}

int ​main()
{
    int x, y, z;

    x = 5; y = 8; z = 10;
    printf("Initial values: x=%d, y=%d, z=%d\n", x, y, z);

    shift(&x, &y, &z);
    printf("Shift:          x=%d, y=%d, z=%d\n", x, y, z);
    
    return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog