Question-Given three variables x, y, z writea 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, cto
circularly shift values.
Solution-
an easy question. let's check the solution.
#include<stdio.h>
int main()
{
int x,y,z; /*i am taking these int, you can choose float */
printf("Enter the value of x,y,z respectively\n");
scanf("%d%d%d",&x,&y,&z);
cirshift(&x,&y,&z);
printf("New values of x=%d\nNew values of y=%d\nNew values of z=%d\n",x,y,z);
return 0;
}
cirshift(int *x,int *y,int *z)
{
int k;
k=*y;
*y=*x;
*x=*z;
*z=k;
return(*x,*y,*z);
}
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, cto
circularly shift values.
Solution-
an easy question. let's check the solution.
#include<stdio.h>
int main()
{
int x,y,z; /*i am taking these int, you can choose float */
printf("Enter the value of x,y,z respectively\n");
scanf("%d%d%d",&x,&y,&z);
cirshift(&x,&y,&z);
printf("New values of x=%d\nNew values of y=%d\nNew values of z=%d\n",x,y,z);
return 0;
}
cirshift(int *x,int *y,int *z)
{
int k;
k=*y;
*y=*x;
*x=*z;
*z=k;
return(*x,*y,*z);
}
No comments:
Post a Comment