I need to print something in a loop everytime a number is 10, 20, 30, 40…
It should only print once and then continue the loop and print again when the number is divisible by 10.
How can I achieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Generally the modulus operator (%) is what you need here. It calculates the remainder of a division. So: 7 % 5 = 2 and 18 % 5 = 3.