top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

how to swap values of two variables in c?

+2 votes

how many types we can swap values of two variables without using third variable?

posted Mar 23, 2015 by Devendra Bohre

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Just going the logic -
Assume you have two variable a and b and you want to swap the value of a and b then try the following logic -


Dry run assume a=5 and b =10
a=a+b means a=15 b=10
b=a-b means a=15 b=5
a=a-b means a=10 b=5

answer Mar 23, 2015 by Salil Agrawal
Similar Questions
+2 votes

How can I wwap value two variables without using third variable or +/- operator?

0 votes

a and b are compared against
the threshold ‘TH’, and the nearest value is voted as output

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.