In the following, I wish for the program to exit if "condition" is less than 3 in function2, but at the moment, it just continues code execution after the switch statement. How do I go about achieving my goal?
#include <iostream>
using namespace std;
int main ()
{
string answer;
int selection;
do
{
cin >> selection;
switch(selection)
{
case 1:
function1();
break;
case 2:
function2();
break;
default:
break;
}
cout << "Anything else?" << endl;
cin >> answer;
}while(!(answer == "no"));
return 0;
}
void function1()
{
//do stuff
}
int function2()
{
int condition;
cin >> conditon;
if(condition < 3)
{
cout << "That's an error." << endl;
return 0;
}
return 0;
}