You execute the following code.
How many times will the word Hello be printed?
A.
49
B.
50
C.
51
D.
100
Explanation:
The mod operator computes the remainder after dividing its first operand by its second. All
numeric types have predefined remainder operators.
In this case the reminder will be nonzero 50 times (for i with values 1, 3, 5,..,99).
c: 51
0 % 2 = 0
2 % 2 = 0
4 % 2 = 0
6 % 2 = 0
8 % 2 = 0
10 % 2 = 0
Total = 6. means for 100 it’s going to be 50 + 1
50 is the correct answer. this is mod 2 0…so every time the answer isn’t 0 is when it will print hello meaning that it skips the “0” iteration. if it were mod 2 = 0 then it would be 51.