0

Can someone explain this question to me? Please

int i = 5; while (i<=15){ if ((i++)%3==0){ System.out.println(i); } } }

17th Nov 2019, 11:10 PM
Jibrilla Abdul-Razak
Jibrilla Abdul-Razak - avatar
3 Respostas
+ 3
that code should return an error since there's a { too much, but otherwise, that code counts from 5 till 15 (15 included) and prints every number in that range which is divisable by 3. so the output is: 6 9 12 15 rewriting the code more readable would be: for(int i=5;i<=15;i++){ if(i % 3 == 0){ System.out.println(i); } }
17th Nov 2019, 11:19 PM
Anton Böhler
Anton Böhler - avatar
0
u need to remove "}" in end
17th Nov 2019, 11:35 PM
Eotd Pro
Eotd Pro - avatar
0
Thanks all...
18th Nov 2019, 9:47 AM
Jibrilla Abdul-Razak
Jibrilla Abdul-Razak - avatar