How many times will "Tricky!" be printed by the following loop?int c = 5; for (int i = 2; i <= c; i++) { for (int j = 0; j < i; j++) { System.out.println("Tricky!"); } }
Answers
Answered by
3
14 times.
You can execute and count it or you can trace it manually and count it or you can count it directly. The "j" loop will run as many times as the "i" value. Since "i" value keeps changing, the end result is the summation of all i.e.,
2+3+4+5=14!
Similar questions