0
C++
I want to ask if you can let user input a specific number you want in c++ Example :user will be to input numbers from 1 to 30 only
3 Answers
+ 4
Alhassan Emmanuel
#include <iostream>
using namespace std;
int main() {
int days;
cin >> days;
if ((days < 1 ) || ( days > 30 )) {
cout << "out of range"; }
else { cout << "whatever you want";}
return 0;
}
+ 2
intro to C++ is waiting for you
0
I think what you have to do is put the input statement in a loop that runs as long as the value is not valid.