First of all i want to say that i am very new to c++ as i have just started learning it at college. My assignment will be issues soon where i need to design a cinema ticket booking system. I have started my program, but i am breaking it down into small chunks.
So i have my first very simple question.
I have created a menu of 5 options using an IF statement, my 5th option is for them to exit the program using an integer. What is the code i need to make them exit the program
int main()
{
int choice;
cout << "1.Hello world \n"<<"...\n"<<"5. Exit the program\n";
cin>> choice;
if (choice == 1)
{
cout << "Hello world";
}else if (choice==5)
{
return 0;
}else {
cout << "no in the list";
}
}
ikra u r dead wrong there r many ways to do it. an easy way is where u want the program to exit early is return anInt; there is also (in the cstdlib library) exit(int) and abort()