0 votes 0 votes Minimum number of temporary variables needed to swap two variables is? Anshita Malviya asked Aug 5, 2018 Anshita Malviya 277 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Shaik Masthan commented Aug 5, 2018 reply Follow Share zero... without using temporary variable also we can swap the variables a=a+b; b=a-b; a=a-b; 3 votes 3 votes pankaj_vir commented Aug 5, 2018 reply Follow Share Zero Logic 1: $a=a+b;$ $b=a-b;$ $a=a-b;$ Logic 2: using XOR $a=a$ ^ $b;$ $b=a$ ^ $b;$ $a=a$ ^ $b;$ 2 votes 2 votes Please log in or register to add a comment.