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 / tamal datta

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("\n Enter a = ");
scanf("%d",&a);
printf("\n Enter b = ");
scanf ("%d",&b);
printf ("\nBefore swapping a = %d",a);
printf ("\nBefore swapping b = %d",b);
//swaping of 2 numbers without using temp variable
a=a+b;
b=a-b;
a=a-b;
printf("\nAfter swapping a = %d",a);
printf ("\nAfter swapping b= %d",b);
getch();
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are multibyte characters?

1190


Why is it that not all header files are declared in every C program?

1280


What is sizeof c?

1120


Is malloc memset faster than calloc?

1128


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

2183


Is c easier than java?

1124


cavium networks written test pattern ..

4140


What is difference between array and pointer in c?

1138


What are global variables?

1265


Explain how do you print an address?

1205


Explain pointer. What are function pointers in C?

1145


What are the advantages of external class?

1122


why do some people write if(0 == x) instead of if(x == 0)?

1124


Explain c preprocessor?

1160


What are valid signatures for the Main function?

1290