This is a very basic program I want to run. The user is asked to choose between a choice of three variant programs, which appear later individually in the code.
I want to only accept integer inputs, with values 1,2,3,4, and 5 for example. For some reason, the current program is only accepting the 1 input, and the while loop repeats indefinitely for a non-integer input.
Can anyone spots these two problems, and suggest some fixes for me? Thanks in advance.
Code:
#include <iostream>
using namespace std;
int main() {
int programversion;
cout << "Which program version would you like to run? Basic [1], advanced [2], or advanced-variant [3]?\n";
cin >> programversion;
while (programversion != (1||2||3))
{
cout << "That is not a correct input integer - please choose [1], [2] or [3]\n";
cin >> programversion;
}
if (programversion == 1)
{
cout << "You chose option 1.\n";
}
if (programversion == 2)
{
cout << "You chose option 2.\n";
}
if (programversion == 3)
{
cout << "You chose option 3.\n";
}
return 0;
}