Can someone please explain why this program does not work? Also, for some reason, I cannot get my cin.get() to pause and await a key press from the user. I know both items are rather simple but I have drawn a blank. Thank you all!
Code:
#include <iostream>
#include <cstdlib>
int choice;
int main()
{
using namespace std;
cout << "Do you want to hear a joke?" << endl;
cout << "Enter y for yes or n for no:" << endl;
cin >> choice;
if (choice == 'y' || choice == 'Y')
{
cout << "\n" << endl;
cout << "What do you call a guy with" << endl;
cout << "no arms and no legs laying on the floor?" << endl;
cout << "\n" << endl;
cin.get();
cout << "Matt!" << endl;
}
else if (choice == 'n' || choice == 'N')
{
cout << "Program will end." << endl;
return 1;
}
return 0;
}