Skip to content

Instantly share code, notes, and snippets.

@jagdish4501
Created May 12, 2021 08:17
Show Gist options
  • Save jagdish4501/9e9b8b070d70db2437533cd86b9f0f55 to your computer and use it in GitHub Desktop.
Save jagdish4501/9e9b8b070d70db2437533cd86b9f0f55 to your computer and use it in GitHub Desktop.
Let us c Q. Given three variables x, y, z write a function to circularly shift their values to right. In other words if x = 5, y = 8, z = 10 after circular shift y = 5, z = 8, x =10 after circular shift y = 5, z = 8 and x = 10. Call the function with variables a, b, c to circularly shift values.
#include <stdio.h>
void fun(int *, int *, int *);
int main()
{
int a, b, c;
printf(" Enter number a :");
scanf("%d", &a);
printf(" Enter number b :");
scanf("%d", &b);
printf(" Enter number c :");
scanf("%d", &c);
printf(" a=%d ,b=%d,c=%d\n", a, b, c);
fun(&a, &b, &c);
printf(" a=%d ,b=%d,c=%d\n", a, b, c);
}
void fun(int *x, int *y, int *z)
{
int temp = *x + *y + *z;
*x = temp - (*x + *y);
*y = temp - (*z + *y);
*z = temp - (*x + *y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment