Please explain 1 string c++. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Please explain 1 string c++.

How it works: if (num % 3 == 0)? https://code.sololearn.com/c9q6htkT7RZh/?ref=app

28th Apr 2022, 9:37 AM
Ivan Horlenko
2 Answers
+ 1
(num % 3) is the reminder of num after dividing by 3. For example, 10 % 3 is 1, 12 % 3 is 0. When num is a multiple of 3, the remainder would be 0. The if statement checks if this is true, in which case it prints num. (null is probably a typo.) So, basically, the while loop iterates over all numbers from 1 to 20 and if the number is a multiple of 3, prints it.
28th Apr 2022, 11:02 AM
m.ali.a
m.ali.a - avatar
0
Thanks a lot, Im watching video right know and just understood)
28th Apr 2022, 6:20 PM
Ivan Horlenko