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
What are the types of data structures in c?
What is difference between %d and %i in c?
What is bubble sort in c?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
What are global variables?
What is meant by initialization and how we initialize a variable?
How can you determine the size of an allocated portion of memory?
write a c program in such a way that if we enter the today date the output should be next day's date.
what is the diffrenet bettwen HTTP and internet protocol
How do you construct an increment statement or decrement statement in C?
a value that does not change during program execution a) variabe b) argument c) parameter d) none
Is python a c language?
Explain what is meant by high-order and low-order bytes?
What is memory leak in c?