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 / toto

#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)
{
p=c;
c=b;
b=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 ?    2 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between scanf and fscanf?

656


What is a macro in c preprocessor?

619


When should a type cast not be used?

620


Where is volatile variable stored?

639


Why can arithmetic operations not be performed on void pointers?

583






What is a spanning Tree?

942


What are the advantages of using macro in c language?

585


#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

711


What are the different types of constants?

636


The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

759


Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58

1114


What is calloc() function?

617


What are the string functions? List some string functions available in c.

596


Differentiate abs() function from fabs() function.

588


What is the use of header files?

594