(This is my first question on Stack Overflow, so please let me know if I can word it better.)
I have a program that lets you open either a calculator or a "number generator". You pick which one to open by entering C or N into the console. The code is pretty complex for me as I just started learning C++ and so I wasn't really able to scope out any issues with it. Also, I have defined all the variables shown and included .
However, no matter what I enter at the beginning (even if it's an invalid answer, like Q or 123), it opens the calculator.
void init()
{
std::cout << "Open calculator or number generator? ( C or N ): ";
std::cin >> firstpick;
}
int main()
{
init();
if (firstpick == 'c' || 'C')
calculator();
else if (firstpick == 'n' || 'N')
numbergen();
else if (firstpick != 'c' && 'n' && 'C' && 'N')
std::cout << "ERROR: Invalid answer to init";
return 0;
}
The expected result is to allow me to open either C or N and to have the program return an error when I enter an invalid answer, but it always opens C no matter what.