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
Why is a semicolon (;) put at the end of every program statement?
int i=10; printf("%d %d %d", i, i=20, i);
What are pointers in C? Give an example where to illustrate their significance.
What was noalias and what ever happened to it?
Write a function that will take in a phone number and output all possible alphabetical combinations
What is the significance of an algorithm to C programming?
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
How can you find out how much memory is available?
How can you return multiple values from a function?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
What is indirection in c?
Explain how can I pad a string to a known length?
What is a constant and types of constants in c?
Explain how can you avoid including a header more than once?
Explain setjmp()?