+ 1
can someone tell me how to make it impossible for a user to type a 'userchoice1[x]' value that does not range from 1 - 10. If you also know a way I can make the user input another value for the 'userchoice1[x]' variable if it is less than 1, I'll appreciate you share the knowledge with me. please see the short code below
for (int x=0; x<5; x++) { cin>>userchoice1[x]; if (userchoice1[x]<1) { cout<<"Number must not be less than 1." <<endl; } }
2 Réponses
+ 4
write again: cin>>userchoise1[x]
+ 2
In the IF block decrement the x so that you still await input to the invalid variable.