I want to express something in C++ but I'm unsure... basically if I enter a number less than 1 or enter ctrl-z, then my program will display a cout message... how do I go about this?
I cant remember how to check for two keys at once but to check if ctrl was pressed you would use the ASCII key for ctrl. For instance if ctrl's ascii code was 36 (which it isn't) you would check it like this
1 2 3
if(num1 == 36) {
//do something
}
note that you use '==' and not '=' when evaluating a boolean expression.
if that's verbatim what you wrote then what you are saying is
if num1 is equal to -1 then
if num1 is equal to '^z' then
do something
or written simpler
if num1 is equal to -1 and '^z' then
do something
this will never be true because num1 cannot be both -1 and '^z' at the same time
what you need to do is use the conditional 'or' operator. In case you don't know it, you type ||.
so your code becomes if(num1 == -1 || num1 == '^z') cout << "the sum is " etc