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 are keywords in c with examples?
Explain the term printf() and scanf() used in c language?
What is difference between && and & in c?
How can a number be converted to a string?
How will you find a duplicate number in a array without negating the nos ?
How can I split up a string into whitespace-separated fields?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
Why does everyone say not to use scanf? What should I use instead?
Is this program statement valid? INT = 10.50;
What is data types?
What is identifier in c?
what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above
What is dynamic dispatch in c++?