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
Explain how can I remove the trailing spaces from a string?
Why is #define used?
Explain the use of 'auto' keyword
Hai what is the different types of versions and their differences
What is the time and space complexities of merge sort and when is it preferred over quick sort?
How pointers are declared?
Explain how can a program be made to print the line number where an error occurs?
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?
Create a simple code fragment that will swap the values of two variables num1 and num2.
What does the c preprocessor do?
What are the types of operators in c?
What is the difference between strcpy() and memcpy() function in c programming?
How main function is called in c?
Write the control statements in C language
What is hash table in c?