Advertisement
Koalaazz

Assignment 3 - Loop

Sep 17th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. //assignment 3
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int number, counter = 2;
  6.  
  7. int main()
  8. {
  9. char again = 'y';
  10. while (again == 'y')
  11. {
  12. //asks for integer
  13. cout << "Enter an integer: " << endl;
  14. cin >> number;
  15. //math and loop
  16. do
  17. {
  18. if (number % counter == 0)
  19. {
  20. cout << "Your number is divisible by: " << counter << endl;
  21. }
  22. counter++;
  23.  
  24. } while (counter <= 9);
  25.  
  26. cout << "\nWould you like to go again? y/n" << endl;
  27. cin >> again;
  28. again = tolower(again);
  29.  
  30. //exit
  31.  
  32. counter = 2;
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement