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 / yash paranjape

a=a^b;
b=a^b;
a=a^b;


i.e
a^=b;
b^=a;
a^=b;

more simplifie i.e in just one line
a^=b^=a^=b;

This also works fine

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between MAC vs. IP Addressing

1144


What is the sizeof () operator?

1077


How can I trap or ignore keyboard interrupts like control-c?

1060


What is the difference between malloc calloc and realloc in c?

1133


How do you define CONSTANT in C?

1267


What are c identifiers?

1083


What are the application of c?

1091


What is a program flowchart and how does it help in writing a program?

1134


FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.

1739


What is const and volatile in c?

1044


For what purpose null pointer used?

1066


What are structure members?

1088


Explain bit masking in c?

1132


Is register a keyword in c?

1033


Can main () be called recursively?

1112