Skip to content

Instantly share code, notes, and snippets.

@paulruescher
Created January 28, 2016 06:37
Show Gist options
  • Save paulruescher/5a881fe2c2341068eae9 to your computer and use it in GitHub Desktop.
Save paulruescher/5a881fe2c2341068eae9 to your computer and use it in GitHub Desktop.
int main()
{
    // Variable declaration
    int choice;
    // Print the main menu
    cout << "CMPT 126 - Assignment 1\n";
    cout << "\nPlease select one of the followings:\n";
    cout << "1\tQuadratic equation solver.\n";
    cout << "2\tReverse an integer and sum its digits.\n";
    cout << "3\tPrint pyramid of digits.\n";
    cout << "4\tExit\n";
    cout << "\nYour choice is: ";
    cin >> choice;
    switch (choice)
    {
        case 1: ans_q1(); break;
        case 2: ans_q2(); break;
        case 3: ans_q3(); break;
        case 4:
        char exit;
        cout << "\nDo you want to exit the program?(y/n)\n";
        cin>> exit;
        if (exit=='n')
            main();
        else if (exit=='y')
        default:
            cout << "Wrong input!" << endl;
            main();
    }
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment