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
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
What does %c mean in c?
Differentiate between static and dynamic modeling.
What are variables and it what way is it different from constants?
#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }
Define Array of pointers.
Is it possible to use curly brackets ({}) to enclose single line code in c program?
Why do we use int main?
Does c have an equivalent to pascals with statement?
What is the scope of global variable in c?
What is the newline escape sequence?
How is actual parameter different from the formal parameter?
Is c object oriented?
Who developed c language?
Array is an lvalue or not?