Computer Science, asked by tarelswar9252, 7 months ago

What will be the output of the following method for: a) f (28,39) b) f (27,39) public boolean f ( int a, int b ) { boolean c = false; while ( a > 1 && b > 1 ) { if ( a > b ) A - = B; else b - = a; } if ( a == 1 | | b == 1 ) c = true; return ( c ); }

Answers

Answered by Anonymous
8

Answer:

What will be the output for the following program in Java?

Be an expert in programming.

This won't run as their is an error

Error -> !! in the if statement isn't a valid Java operator.

It might be rectified by replacing it with the logical OR || operator.

class Main {

public static boolean f(int a, int b) {

boolean e = false;

while (a > 1 && b > 1) {

if (a > b) {

a -= b;

} else {

b -= a;

}

}

if (a == 1 || b == 1) {

e = true;

}

return e;

}

public static void main (String[] args) {

int a = 28;

int b = 39;

System.out.print(f(a,b));

}

}

Similar questions