Advertisement
Guest User

new

a guest
Jun 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.    
  6.     // Declare Variables
  7.     int userInput;
  8.     int countDvs5 = 0;
  9.     int countDvs3 = 0;
  10.    
  11.     while(userInput != -1){
  12.         cout << "Enter Number: ";
  13.         cin >> userInput;
  14.        
  15.         // Check if input can be divisible 3
  16.         // Plus 1 if true
  17.         if(userInput % 3 == 0){
  18.             countDvs3 = countDvs3 + 1;
  19.         }
  20.        
  21.         // Check if input can be dividible 5
  22.         // Plus 1 if true
  23.         if(userInput %5 == 0){
  24.             countDvs5 = countDvs5 + 1;
  25.         }
  26.    
  27.     }
  28.  
  29.     cout << "There are " << countDvs3 << " numbers that can be divisible by 3." << endl;
  30.    
  31.     cout << "There are " << countDvs5 << " numbers that can be divisible by 5." << endl;
  32.    
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement