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 / vignesh1988i
this will work correctly.....vignesh1988i
#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 ? | 7 Yes | 7 No |
Post New Answer View All Answers
What is identifier in c?
What is the basic structure of c?
What is the size of a union variable?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What does %c do in c?
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
In c language can we compile a program without main() function?
What does sizeof function do?
Implement bit Array in C.
how do you programme Carrier Sense Multiple Access
if p is a string contained in a string?
What is the code in while loop that returns the output of given code?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
what will be maximum number of comparisons when number of elements are given?