Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why is a semicolon (;) put at the end of every program statement?

1032


int i=10; printf("%d %d %d", i, i=20, i);

1550


What are pointers in C? Give an example where to illustrate their significance.

1170


What was noalias and what ever happened to it?

979


Write a function that will take in a phone number and output all possible alphabetical combinations

1001


What is the significance of an algorithm to C programming?

1001


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)

2247


How can you find out how much memory is available?

1016


How can you return multiple values from a function?

1053


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

1096


What is indirection in c?

1025


Explain how can I pad a string to a known length?

1128


What is a constant and types of constants in c?

1071


Explain how can you avoid including a header more than once?

1045


Explain setjmp()?

1011