如果我输入大于 5 或小于 1 的数字,我应该会收到一条声明说输入错误。但是,它只告诉我代码已完成,并且在我运行它时不会打印语句
if (choice >= 1 || choice <= 5)
{
switch (choice)
{
{case 1:
int result = a + b;
cout << result << endl;
break;}
{case 2:
int result = a - b;
cout << result << endl;
break; }
{case 3:
int result = a * b;
cout << result << endl;
break;}
{case 4:
double result = a / (double)b ;
cout << result<< endl;
break;}
{case 5:
int result = a % b;
cout << result << endl;
break;}
}
}
else
{cout <<"Wrong entry" << endl;}
return 0;
}