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
SINCE THE SWAPPING OF THREE NUMBERS WILL HAVE 3! OF
COMBINATIONS.... I AM KEEPING THE LIMIT VALUE AS 6.
#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)
{
if(b>c)
p=b-c;
else
p=c-b;
b=p+b;
b=a+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 ? | 6 Yes | 8 No |
Post New Answer View All Answers
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
Is this program statement valid? INT = 10.50;
What does. int *x[](); means ?
Explain how do you determine a file’s attributes?
What is main function in c?
Can we initialize extern variable in c?
What is structure in c language?
what do you mean by enumeration constant?
Explain what is the difference between the expression '++a' and 'a++'?
What is the use of header?
When should the volatile modifier be used?
How is a pointer variable declared?
write a program to rearrange the array such way that all even elements should come first and next come odd
What is c variable?