i do not know if this it a TRUE statement

Consider the following declarations:

int score = 80;
char answer = ‘N’;
int n = 8;
char ch = ‘a’;

( (ch >= ‘A’) && (ch <= ‘Z’) )
no. 'a' is not between 'A' and 'Z'. 'a' is between 'a' and 'z'. There is a difference. See ASCII table. If ch is entered by user and you want to check if it is between 'a'/'A' and 'z'/'Z' you could use tolower().
Technically the C++ standard does not prohibit an implementation where this is true, however you won't find one in practice.
However, I think the real question was whether the comparison is case-insensitive, which hamsterman already addressed.
Last edited on
The syntax is also incorrect. Single quotes are like this: '
so this is a FALSE statement because a is not between A and Z?
1
2
char ch = 'a';
ch >= 'A' && ch <= 'Z';

The expression evaluates to false (not FALSE) because 'a' is not between 'A' and 'Z'. There are no statements in that expression, though.
thank you
Remember to use 's, has moorecm already told.
Here's an ASCII table:
http://www.asciitable.com/

The red Chr column has the characters and the Dec column has their corresponing decimal values.

A = 65
...
Z = 90

a = 97
...
z = 122
Topic archived. No new replies allowed.