0

# need help solve this

int a=15 ; int b=3; int temp; temp=a; a=b; b=temp; cout<<temp/a;

4 Answers

+ 8

int a=15 ; int b=3; int temp;
temp=a; // temp is 15, a is 15, b is 3
a=b; // temp is 15, a is 3, b is 3
b=temp; // temp is 15, a is 3, b is 15
cout<<temp/a; // temp/a is 15/3
// outputs 5

+ 1

a=15 , b=3
temp= a , a=b, b=temp
temp=15 , a=3, b=15
so temp/a=5

0

5

0

temp=15
a=3
b=temp
so what you are doing is dividing temp(15)/a(3)