Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- // Declare Variables
- int userInput;
- int countDvs5 = 0;
- int countDvs3 = 0;
- while(userInput != -1){
- cout << "Enter Number: ";
- cin >> userInput;
- // Check if input can be divisible 3
- // Plus 1 if true
- if(userInput % 3 == 0){
- countDvs3 = countDvs3 + 1;
- }
- // Check if input can be dividible 5
- // Plus 1 if true
- if(userInput %5 == 0){
- countDvs5 = countDvs5 + 1;
- }
- }
- cout << "There are " << countDvs3 << " numbers that can be divisible by 3." << endl;
- cout << "There are " << countDvs5 << " numbers that can be divisible by 5." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement