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 are the advantages of c preprocessor?
Are the outer parentheses in return statements really optional?
Do character constants represent numerical values?
Explain what is the benefit of using const for declaring constants?
What is the use of #include in c?
Is it possible to execute code even after the program exits the main() function?
What is printf () in c?
Do you know pointer in c?
What is typedef?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
How can a process change an environment variable in its caller?
What is the use of ?: Operator?
Is flag a keyword in c?
What is const volatile variable in c?