Which three are valid declarations of a char? - ProProfs Discuss
Advertisement

Which three are valid declarations of a char?

Asked by , Last updated: Apr 17, 2024

+ Answer
Request
Question menu
Vote up Vote down

1 Answer

Answered Aug 31, 2018

Char c1 = 064770;
Char c3 = 0xbeef;
Char c6 = \uface ;

(1), (3), and (6) are correct. char c1 = 064770; is an octal representation of the integer value 27128, which is legal because it fits into an unsigned 16-bit integer. char c3 = 0xbeef; is a hexadecimal representation of the integer value 48879, which fits into an unsigned 16-bit integer. char c6 = \uface; is a Unicode representation of a character. char c2 = face; is wrong because you cant put more than one character in a char literal. The only other acceptable char literal that can go between single quotes is a Unicode value, and Unicode literals must always start with a \u. char c4 = \u0022; is wrong because the single quotes are missing. char c5 = \iface; is wrong because it appears to be a Unicode representation (notice the backslash), but starts with \i rather than \u.
upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.