Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #define MAX_NUM 21
  5.  
  6. int main(){
  7.  
  8.     int n, suma = 0;
  9.  
  10.     do {
  11.        
  12.         cout << "Enter a number: ";
  13.         cin >> n;
  14.  
  15.         if( n > 5 or n < 1){
  16.        
  17.             cout << "Number invalid." << endl;
  18.  
  19.         } else {
  20.  
  21.             suma += n;
  22.             cout << "Number valid. Current result is " << suma << "." << endl;
  23.  
  24.         }
  25.  
  26.         cout << endl;
  27.  
  28.     } while( suma < MAX_NUM );
  29.  
  30.  
  31.     cout << "Count surpased " << MAX_NUM << ", the final result is " << suma << "." << endl;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement