asked 112k views
5 votes
To check whether a char variable ch is an uppercase letter, you write ________.

a.(ch >= 'A' && ch <= 'Z')
b.('A' <= ch <= 'Z')
c.(ch >= 'A' && ch >= 'Z')
d.(ch >= 'A' || ch <= 'Z')

asked
User Keylla
by
7.8k points

1 Answer

4 votes

Final answer:

To check whether a char variable ch is an uppercase letter, you write (ch >= 'A' && ch <= 'Z').

Step-by-step explanation:

To check whether a char variable ch is an uppercase letter, you write (ch >= 'A' && ch <= 'Z'). Option a is the correct answer. This expression checks if the character ch is greater than or equal to 'A' and less than or equal to 'Z', which are the ASCII values for uppercase letters. If the condition is true, then the char variable ch is an uppercase letter.

answered
User AlixB
by
8.6k points