Write a program that takes three variables(a,b,c) in as
separate parameters and rotates the values stored so that
value a goes to b,b,to c and c to a
Answer Posted / toto
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,p;
printf("enter the three values :");
scanf("%d%d%d",a,b,c);
printf("a=%d\nb=%d\nc=%d\n ",a,b,c);
for(int i=1;i<=6;i++)
{
if(i%2==1)
{
p=c;
c=b;
b=p;
printf("a=%d\nb=%d\nc=%d\n",a,b,c);
}
else
{
a=a+b;
if(a>b)
b=a-b;
else
b=b-a;
a=a-b;
printf("a=%d\nb=%d\nc=%d\n ",a,b,c);
}
}
getch();
}
| Is This Answer Correct ? | 2 Yes | 7 No |
Post New Answer View All Answers
What does %c mean in c?
What is difference between array and structure in c?
How can a number be converted to a string?
Is there a way to jump out of a function or functions?
what is the significance of static storage class specifier?
What are the types of bitwise operator?
Tell us the use of fflush() function in c language?
What is scope and lifetime of a variable in c?
What is structure in c definition?
What is the difference between abs() and fabs() functions?
Was 2000 a leap year?
Explain argument and its types.
What is main function in c?
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
What the different types of arrays in c?