write a program to swap Two numbers without using temp variable.

Answer Posted / swechha

a=a-b
b=a+b
a=b-a

if a=5 and b=10 then
a=5-10=(-5)
b=(-5)+10=5
a=5-(-5)=5+5=10

now a=10 & b=5

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by keywords in c?

614


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

596


What is void main () in c?

722


What are data structures in c and how to use them?

663


What is const and volatile in c?

560






What is the use of ?: Operator?

660


What is c value paradox explain?

563


What are the functions to open and close file in c language?

721


What is pointers in c?

640


How can I make sure that my program is the only one accessing a file?

666


What is the use of static variable in c?

587


Hi can anyone tell what is a start up code?

1607


What are the preprocessor categories?

628


What are the storage classes in C?

617


Why is c still so popular?

607