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 are the different flags in C? And how they are useful? And give example for each in different consequences?

1 Answers  


Write a program in C for showing working of different logical operator in C. Your program should guide users with proper message/menu on the console.

3 Answers   HCL,


Explain how can I make sure that my program is the only one accessing a file?

0 Answers  


Is c programming hard?

0 Answers  


What is extern storage class in c?

0 Answers  






write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

0 Answers   Google,


Can a program have two main functions?

0 Answers  


what is the defrenece between structure and union

5 Answers   Aloha Technology,


What is time null in c?

0 Answers  


24.what is a void pointer? 25.why arithmetic operation can’t be performed on a void pointer? 26.differentiate between const char *a; char *const a; and char const *a; 27.compare array with pointer? 28.what is a NULL pointer? 29.what does ‘segmentation violation’ mean? 30.what does ‘Bus Error’ mean? 31.Define function pointers? 32.How do you initialize function pointers? Give an example? 33.where can function pointers be used?

0 Answers  


What are the advantages of using linked list for tree construction?

0 Answers  


What is #define in c?

0 Answers  


Categories