Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. int num1 = 1; // declaring two variables as integers
  2. int counter = 1;
  3.  
  4. while (counter <= 100) // loop will continue to run while counter is below 100
  5. {
  6. if (num1 % 5 == 0) // this will check if a number is a multiple of 5 by checking whether or not the modulus is 0
  7. {
  8. cout << num1 << endl;
  9. num1++; //these three lines will if the number is a multiple of 5 it will be shown on the screen and then a new line will be started as well as increasing the variables by 1
  10. counter++;
  11. }
  12. else
  13. {
  14. num1++; // theses two lines will increas the variables by 1 everytime they occur
  15. counter++;
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement