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
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 |
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 |
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 |
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 |
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 |
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 |
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 |
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
Is the below things valid & where it will be stored in memory layout ? static const volatile int i; register struct { } ; static register;
What is the size of a union variable?
What is c basic?
What is volatile variable in c with example?
how to write a c program to print list of fruits in alpabetical order?
what is out put of the following code? #include class Base { Base() { cout<<"constructor base"; } ~Base() { cout<<"destructor base"; } } class Derived:public Base { Derived() { cout<<"constructor derived"; } ~Derived() { cout<<"destructor derived"; } } void main() { Base *var=new Derived(); delete var; }
Why we use break in c?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? 1) Quicksort 2) Linear Search 3) Bubble Sort
what is linkage error when it occurs in c program
main() { int a,b; printf("%d,%d",scanf("%d%d",&a,&b)); } => do u mean above program's output... =>output will be:2,whatever you enter value for b. =>because scanf is a library fn which will return how many arguements it processes, and second value you are right mr.Satya but i found my self unable to understand that for the first time scanf returns the no of successful matches but how for the second time it returns the value of 'b'.while a function should return the same 'r' value every time.