Computer Science, asked by khushboo6770, 1 year ago

2. void test 2(int a, int b)
while( a != b)
if ( a > b)
a = a - b;
else
a = b - a;
System.out.println(a);
if 4 and 17 are passed to the function.

Answers

Answered by sswaraj04
10

Answer:

it's an infinite loop.......

Explanation:

4<17

a=17-4=13

13!=17 true

13<17

a=17-13=4

4!=17 true

4<17

a=17-4=13

....till eternity


khushboo6770: thankyou so much if you don't mind can you please answer some more question
sswaraj04: hmm fine which ones
khushboo6770: thanks a lot
Answered by anaypalclassx
1

while( 4 != 17)-it is true.

if ( 4> 17)- it is false. So it directly comes to else state ment

a = a - b;

a = a - b;else

a = a - b;elsea = 17 - 4;

;System.out.println(a);

hence, a= 13.

Similar questions