122k views
5 votes
Int a = 10;

int b = 5;

int remainder = a % b;

if ( remainder != 0)

if ( remainder == 1)

System.out.print(a);

else

System.out.print(b);


Answer: ______________________


What would be the answer I'm super confused

1 Answer

4 votes

Answer:

System output is nothing

Step-by-step explanation:

int a = 10;

int b = 5;

int remainder = a % b;

if ( remainder != 0)

if ( remainder == 1)

System.out.print(a);

else

System.out.print(b);

a%b result is 0 so it will not go into the any of the if statements and exit without printing anything. Please try the below C++ program then you will see.

#include <iostream>

using namespace std;

int main ()

{

int a = 10;

int b = 5;

int remain = a % b;

if ( remain != 0)

if ( remain == 1)

cout<<a;

else

cout<<b;

return 0;

}

User Mathew
by
8.0k points