Computer Science, asked by av1266108, 10 months ago

How many times is the println statement executed?
for (int i = 1; i <= 5; i++)
for (int j = 1; j <= 5; j++)
if (i == j)
System.out.println(i * j);​

Answers

Answered by shaira07
2

Answer:

5 times ...

Explanation:

first time i is 1 ...and i is less than 5 ... therefire the condition satisfies ...so the inner loop executes..and first time j is 1 ..it further checks the condition j is less than equal to 5...then it finally enters the if condition...in the first time i=j=1 ; the condition satisfies and therefore the print statement executes....then j value keeps on increasing till it is equal to 5 , but the if condition doesn't satisfy bcoz i value is 1 ....now again the working goes to the outer loop ..the value of i becomes 2 , it comes into the inner loop where the j value is 1 and the if condition doesn't satisfy...then the j value increases so the if condition satisfies i.e. i=j=2 ; so the print statement executes; this keeps on repeating and the third time i value is 3....the fourth time i value is 4 and at last i value is 5 ...so the print statement executes only if the if condition satisfies....so it executes only 5 times.....

Answered by vilakshnavijaya019
0

Answer:

25

Explanation:

because the answer of i is 5 and j is 5

so aa it is written i*j so 5*5=25

Similar questions