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


Please Help Members By Posting Answers For Below Questions

Explain how can I remove the trailing spaces from a string?

621


Why is #define used?

786


Explain the use of 'auto' keyword

668


Hai what is the different types of versions and their differences

1482


What is the time and space complexities of merge sort and when is it preferred over quick sort?

671






How pointers are declared?

556


Explain how can a program be made to print the line number where an error occurs?

686


write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?

2401


Create a simple code fragment that will swap the values of two variables num1 and num2.

802


What does the c preprocessor do?

613


What are the types of operators in c?

606


What is the difference between strcpy() and memcpy() function in c programming?

622


How main function is called in c?

620


Write the control statements in C language

642


What is hash table in c?

562