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

Answers were Sorted based on User's Feedback



Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values..

Answer / rajesh bhansali

#include<stdio.h>

main()
{
int x, y, z, a;
printf("Type values of x, y and z\n");
scanf("%d %d %d",&x,&y,&z);
printf("On rotation we found the following values
assigned to x,y,z.\n");
a=z;
z=x;
x=y;
y=a;
printf("x=%d, y=%d, z=%d", x,y,z);
getch();
}

Is This Answer Correct ?    62 Yes 12 No

Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values..

Answer / likhit gatagat

#include<stdio.h>

main()
{
int a,b,c,p,q,r;
printf("Enter three numbers:\n");
Scanf("%d%d%d",&a,&b,&c);
p=a;
q=b;
r=c;
b=p;
c=q;
a=r;
printf("%d%d%d",a,b,c);
}

Is This Answer Correct ?    17 Yes 8 No

Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values..

Answer / maddy :)

#include <stdio.h>
#include <conio.h>
void main()
{
int x=1,y=2,z=3,s=0;
s=x,x=y,y=z,z=s;
printf("The value of x=%d,y=%d,z=%d",x,y,z);
}

Is This Answer Correct ?    7 Yes 3 No

Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values..

Answer / nitin

void main()
{
int a,b,c;
printf("enter the values of a,b &c");
scanf("%d%d%d",&a,&b,&c);
c=c+a;
a=c-a;
c=c+b;
b=c-b;
c=c-b;
printf("\n values of ab & c are=%d%d%d",a,b,c);
getch();
}

Is This Answer Correct ?    5 Yes 3 No

Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values..

Answer / vignesh1988i

this will work correctly.....vignesh1988i

#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 ?    7 Yes 7 No

Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values..

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

Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values..

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

More C Interview Questions

What is meant by int main ()?

0 Answers  


how to find turn around time in operating system?

3 Answers  


How can you increase the size of a dynamically allocated array?

0 Answers   TISL,


What is nested structure with example?

0 Answers  


Tell us something about keyword 'auto'.

0 Answers  


In c programming language, how many parameters can be passed to a function ?

0 Answers  


Explain two-dimensional array.

0 Answers  


Explain low-order bytes.

0 Answers  


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

0 Answers  


What is getch?

0 Answers  


What is function prototype in c language?

0 Answers  


Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates

3 Answers  


Categories