Ad Code

Responsive Advertisement

swapping of two numbers in c without temporary variable

 

Swapping of two numbers in c without temporary variable 

C Program:

Output 1:

swapping of two numbers in c without temporary variable


From the above program,

ü Let a=5 and b=6.

ü Here add and sub operations used to swap the variables.

ü a=a+b;(a=5+6=11)(a=11)

b=a-b;(b=11-6=5)(b=5)

a=a-b;(a=11-5=6)(a=6).

ü Finally, a=6 and b=5.

 

Post a Comment

0 Comments

Close Menu