Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the purpose of scanf() and printf() functions?

1170


Explain what does the format %10.2 mean when included in a printf statement?

1289


What is methods in c?

1031


What is scanf_s in c?

1063


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

1202


What is the purpose of void pointer?

984


Explain how can I open a file so that other programs can update it at the same time?

1055


using for loop sum 2 number of any 4 digit number in c language

2253


How can a program be made to print the line number where an error occurs?

1035


How do you list files in a directory?

1074


Function calling procedures? and their differences? Why should one go for Call by Reference?

1040


How many keywords (reserve words) are in c?

1083


What is the use of gets and puts?

968


What is property type c?

1041


What is structure in c definition?

982