Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define MAX_NUM 21
- int main(){
- int n, suma = 0;
- do {
- cout << "Enter a number: ";
- cin >> n;
- if( n > 5 or n < 1){
- cout << "Number invalid." << endl;
- } else {
- suma += n;
- cout << "Number valid. Current result is " << suma << "." << endl;
- }
- cout << endl;
- } while( suma < MAX_NUM );
- cout << "Count surpased " << MAX_NUM << ", the final result is " << suma << "." << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement