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 ?    60 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

WRITE A PROGRAM IN C TO MULTIPLY TWO 2-D ARRAYS

4 Answers  


What is structure packing ?

2 Answers   HP,


What's the difference between DELETE TABLE and TRUNCATE TABLE commands?

2 Answers   CTC,


what is pointer?

4 Answers  


Explain the use of #pragma exit?

0 Answers  






why programming language C is still used in operating system's kernel??

1 Answers   Wipro,


Hi, main() { } Is a user defined function or Built in Functionn

26 Answers   Honeywell, Yahoo,


write an algorithm which can find the largest number among the given list using binary search ............... this was asked in the interview

2 Answers   Satyam, UNIS, Wipro,


write a program to swap bits in a character and return the value prototype of function char fun (char a, charb flag c) where fun returns a char, char a is a the value char b is the bit to be changed and flag c is the bit value for eg: x=fun(45,7,0) since 45 is 0010 0101 and ow x should contain the value 65 (0110 0101)

1 Answers   Bosch, College School Exams Tests,


given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the array which of the following is incorrect? a.*(a+5) b.a[5] c.pa[5] d.*(*pa + 5)

6 Answers   amu, TCS,


What is dangling pointer in c?

0 Answers  


Do pointers take up memory?

0 Answers  


Categories