So I just started to take up C++ again and doing some refresher coding and I'm having some trouble here. I wrote up a random program on visual C++ express and compiled it from this:
The problem is that I can't get the "Press any key to quit this program." to show up. The program would instantly exit when I enter 0. Everything else seems to work fine.
Code:
#include <iostream>
#include <ostream>
using namespace std;
int main()
{
int number;
int result;
int choice;
do{
cout << "\n";
cout << "0 - Quit the program. \n";
cout << "1 - Multiplier tool. \n";
cout << "Enter choice here: ";
cin >> choice;
if (choice == 1){
cout << endl;
cout << "Enter a number to be multiplied by 3: ";
cin >> number;
cin.ignore();
result = number*3; //action
cout << "The result is " << result << " Thank you! Press any key to exit the program.\n";
}//end of if code
if (choice != 1 || 0){
cout << endl;
cout << "Error! Please enter a 1 or 0. \n";
}
}while(choice!=0);//end of do code
cout << "Press any key to quit this program.";
cin.get();
return 0;
}
The problem is that I can't get the "Press any key to quit this program." to show up. The program would instantly exit when I enter 0. Everything else seems to work fine.