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
How can a string be converted to a number?
Why is this loop always executing once?
How do you search data in a data file using random access method?
how many key words availabel in c a) 28 b) 31 c) 32
int far *near * p; means
What is the difference between int main and void main in c?
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
main() { printf("hello"); fork(); }
What is declaration and definition in c?
Explain the array representation of a binary tree in C.
What is return type in c?
What is static memory allocation?
Write a C program in Fibonacci series.
Write a program to check whether a number is prime or not using c?
Do you know the difference between exit() and _exit() function in c?