16,882 views
2 votes
2 votes

The minimum number of temporary variables needed to swap the contents of two variables is:

(a) 1     (b) 2

(c) 3     (d) 0

3 Answers

Best answer
2 votes
2 votes
var a ,b;

a=a+b;

b=a-b;

a=a-b;

or

a=a*b;

b=a/b;

a=a/b;
 no temporary variables is needed
selected by
0 votes
0 votes
#include <stdio.h>
int main(void) {
    int a=5;
    int b=4;
    a=a^b;
    b=a^b;
    a=a^b;
    printf("%d %d",a,b);
    return 0;
}

Related questions

7 votes
7 votes
1 answer
1
admin asked Sep 16, 2015
5,542 views
If a 3 bit multiplicand is multiplied to a 2 bit multiplier, minimum number of two input AND, XOR, and OR gates, needed in the design are respectively?A)    16,14,1B) �...
2 votes
2 votes
2 answers
2
sh!va asked Jul 9, 2016
835 views
The minimum number of radix-64 digits needed to represent an unsigned 64-bit binary number is (A) 10(B) 11(C) 12(D) None of these
6 votes
6 votes
3 answers
4
GateAspirant999 asked Oct 11, 2016
9,626 views
The truth table for the combinational circuit is shown below:What is the minimum number of two input NAND gates required to realize this logic circuit?