4.12: Comparing Characters and String Objects
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is NOT a letter.
!((x >= 'A' && x <='Z') || (x >= 'a' && x <='z'))
Assume that c is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if c is NOT what is called a whitespace character (that is a space or a tab or a newline-- none of which result in ink being printed on paper).
!(c == ' ' || c== '\n' || c == '\t')
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is NOT a upper-case letter.
!(x >= 'A' && x <='Z')
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is an hexadecimal (Base 16) digit (0-9 plus A-F or a-f).
( ( x>='0' && x<='9') || ( x>='a' && x<='f' ) || ( x>='A' && x<='F') )
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is NOT a letter.
((x>='A' && x<='Z') || (x>='a' && x<='z'))
Assume that c is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if c is what is called a whitespace character (that is a space or a tab or a newline-- none of which result in ink being printed on paper).
(c == ' ' || c== '\n' || c == '\t')
Assume that c is a char variable that has been declared and already given a value . Write an expression whose value is true if (c == '\n')and only if c is an newline character .
(c == '\n')
Assume that c is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if c is a tab character .
(c=='\t')
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is an octal (Base 8) digit (0-7).
(x>='0' && x<='7')
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is a decimal digit (0-9).
(x>='0' && x<='9')
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is a upper-case letter.
(x>='A' && x<='Z')
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is a letter.
(x>='A' && x<='Z') || (x>='a' && x<='z')
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is alphanumeric , that is either a letter or a decimal digit.
(x>='A' && x<='Z') || (x>='a' && x<='z') || (x>='0' && x<='9')
Assume that x is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if x is a lower-case letter.
(x>='a' && x<='z')
What's the difference in ASCII value between '3' and '0'? (consult a table of ASCII values):
3
What's the difference in ASCII value between 'E' and 'A'? (consult a table of ASCII values): http://www.asciitable.com
4
What's the difference in ASCII value between 'e' and 'a'? (consult a table of ASCII values):
4
What's the difference in ASCII value between '6' and '0'? (consult a table of ASCII values):
6
Assume that c is a char variable that has been declared and already given a value . Write an expression whose value is true if and only if c is a space character .
c == ' '
Assume that s is a string . Write an expression whose value is true if and only if the value of s would come between "mortgage" and "mortuary" in the dictionary.
s > "mortgage" && s < "mortuary"