0

Ok now i am having a retarded issue im sure. but here is what is supose to happen is n is not allowed to be more than 5 but when i run this and enter in 5 i get a blank space and when i enter 1-4 i get the error meassage. For reasons beyond me i can't figure it out.

void problem8(){
unsigned seed = time(0);
    srand(seed);
    int num1=rand()%90+10;
    int num2=rand()%90+10;
    int n=0;//choice

    cout<<"Choice 1: addition, 2: subtraction, 3: multiplication, 4: division, 5: to end\n";
    cin>>n;
    while(n<=5){
       cout<<"Choice 1 for addition, 2 for subtraction, 3 for multiplication, 4 for division, 5 for ending the program\n"; 
       cin>>n;
    }
    ...
  }

Edited by angrymasteryoda

4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by WaltP
0

could you post the details of those error message

judging from the code you posted there shoudn't be any error regarding input

Edited by zeroliken: added info

0

If you want to restrict input to integers in [1, 5], your while condition should be different.

One way to do it is by using two relational operators and the logical OR operator.

0

Read your condition while(n<=5) cout error out loud and listen/think about what you're saying. Does that condition do what you want?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.