Character Types(C++ Programming ) Questions and Answers
Explanation:-
Answer: Option D. -> CHAR_BITNone.
Explanation:-
Answer: Option B. -> 1The standard does NOT require a char to be 8-bits, but does require that sizeof(char) return 1.
Explanation:-
Answer: Option C. -> Yes, they are differentIn C++, sizeof('a') == sizeof(char) == 1. In C however, sizeof('a') == sizeof(int).
Explanation:-
Answer: Option C. -> Implementation dependentThe standard does not specify if plain char is signed or unsigned. There are three distinct character
types according to the standard: char, signed char and unsigned char.
Question 5.
What is the output of this program?
1.
#include
2.
int main()
3.
{
4.
char a = '\012';
5.
6.
printf("%d", a);
7.
return 0;
8.
}
- Compiler error
- 12
- 10
- Empty
Explanation:-
Answer: Option C. -> 10The value '`setminus`012' means the character with value 12 in octal, which is decimal 10.
Explanation:-
Answer: Option D. -> both a and bwchar_t and char is used to represent wide character and character.
Explanation:-
Answer: Option A. -> L'a'A wide character is always indicated by immediately preceding the character literal by an L.
Explanation:-
Answer: Option C. -> JThe literal value for 74 is J. So it will be printing J.
Explanation:-
Answer: Option C. -> both 1 and 2 are trueEvery character constant has an integer value. Also char belongs to the integral type hence arithmetic
and logical operations can be performed on them.
Explanation:-
Answer: Option B. -> 128None.