54.3k views
5 votes
Assume that x is a char variable 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).

1 Answer

3 votes

Answer: x in [0-9A-Fa-f]

Explanation:

Depends upon syntax of your programming language, but you will write either a string comparison or a regex with the character set defined as above

User Christopher Rogers
by
3.6k points