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...

How many ways are there to swap two numbers without using
temporary variable? Give the each logic.

Answer Posted / alok bajpai

You can swap two Numbers without using temporary variable
with the help of EX-OR operator;

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter the first No.:");
scanf("%d",&a);
printf("Enter the second No.:");
scanf("%d",&b);
a^=b^=a^=b;
printf("%d %d",a,b);
getch();
}

Is This Answer Correct ?    19 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is structure important for a child?

1148


in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above

1084


What are pointers in C? Give an example where to illustrate their significance.

1272


What is difference between && and & in c?

1157


Can a variable be both static and volatile in c?

1080


What is bubble sort technique in c?

1039


How can I change their mode to binary?

1185


What does the file stdio.h contain?

1119


What is break statement?

1179


What is union and structure in c?

1286


can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

1971


How to write a code for reverse of string without using string functions?

2200


How can a string be converted to a number?

1066


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

1102


What is a null string in c?

1103