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 is difference between far and near pointers?
What is the use of #define preprocessor in c?
What is main function in c?
Write a program to print fibonacci series using recursion?
What are reserved words?
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
What are the 3 types of structures?
Do pointers store the address of value or the actual value of a variable?
How can type-insensitive macros be created?
How do you use a 'Local Block'?
Write a Program to accept different goods with the number, price and date of purchase and display them
What are the different types of errors?
in linking some of os executables are linking name some of them
Is there anything like an ifdef for typedefs?
Explain how do you determine a file’s attributes?