write a program to swap Two numbers without using temp variable.
Answer Posted / ratna
#include<stdio.h>
main()
{
int x,y;
printf("\n enter the two numbers:\n");
scanf("%d%d",&x,&y);
y=(x+y)-y;
x=(x+y)-x;
printf("\n x=%d \n y=%d\n");
getch();
}
output: enter the two numbers:10
20
execute the conditions y=30-20=10
x=30-10=20
finally display the output:20 10
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is the purpose of scanf() and printf() functions?
Explain what does the format %10.2 mean when included in a printf statement?
What is methods in c?
What is scanf_s in c?
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
What is the purpose of void pointer?
Explain how can I open a file so that other programs can update it at the same time?
using for loop sum 2 number of any 4 digit number in c language
How can a program be made to print the line number where an error occurs?
How do you list files in a directory?
Function calling procedures? and their differences? Why should one go for Call by Reference?
How many keywords (reserve words) are in c?
What is the use of gets and puts?
What is property type c?
What is structure in c definition?