Discussion
A char variable can store either an ASCII character or a Unicode character.
Answer: A
Correct answer: False
In C a char is one byte - sizeof(char) is 1 by definition - and on ordinary implementations that is eight bits, giving 256 possible values. That is ample for ASCII, which uses only the codes 0 to 127, but Unicode defines over a million code points, so a single char cannot hold an arbitrary Unicode character. C provides other types for that work: wchar_t for wide characters, and since C11 char16_t and char32_t for UTF-16 and UTF-32 code units, declared in <uchar.h>. What a char array can hold is a Unicode character encoded in UTF-8, but that takes one to four char elements per character, not one - the character is spread across several bytes rather than stored in a single variable. The confusion usually comes from Java, where char is a 16-bit UTF-16 code unit and the statement would be much closer to true. In C it is false.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development