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 temporary
variable?

Answer Posted / guest

[code]

main()
{
int a=10;
int b=20;
printf("a = %d\nb = %d\n",a,b);
a =a+b; b=a-b; a=a-b; // This is first way.

a =a*b; b=a/b; a=a/b;
printf("a = %d\nb = %d\n",a,b);
}
[/code]

[code]
main()
{
int a=10;
int b=20;
printf("a = %d\nb = %d\n",a,b);
a =a*b; b=a/b; a=a/b; //This is second way
printf("a = %d\nb = %d\n",a,b);
}
[/code]




Is This Answer Correct ?    19 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of getch ()?

1076


Explain function?

1086


write a program to concatenation the string using switch case?

2096


Can a void pointer point to a function?

1020


Should I learn data structures in c or python?

1017


What are pointers? What are stacks and queues?

1148


Explain is it valid to address one element beyond the end of an array?

1209


Why is it important to memset a variable, immediately after allocating memory to it ?

2070


Tell us something about keyword 'auto'.

1071


Why do we write return 0 in c?

1049


program for reversing a selected line word by word when multiple lines are given without using strrev

2477


Describe the steps to insert data into a singly linked list.

1070


What are control structures? What are the different types?

1086


What are external variables in c?

1100


What is character set?

1166