224 views
for(int i=0; i<=100;i++) {
if (i % 3 == 0)
printf("Great);
if(i%5 == 0)
printf("India");
}

Count the number of times GreatIndia is printed.

1. 6
2. 20
3. 33
4. none of these
edited | 224 views
0

the answer should be $21$, please solve again.

0
Okay it means I have to take every possible combination of multiple of 3 and 5 here
0
For I = 0 nothing will be will be printed
0
$i=0$

"GreatIndia" will be printed.
0
For i=0 great india will be printed.
0
how 0 mod 3 wouldn't be equal to zero
0
0 mod 3 means remainder when we divide 0 by 3 so it is 0
0
Okay got confused it's zero is divided by three not the other way
0
if this question comes in gate then we will execute the loop step by step for 100 times ?
0

@ no, we can observe how condition satisfied and generalize the condition.

1
+1 vote
2