1. How many characters are specified in the ASCII scheme?
a) 64
b) 128
c) 256
d) none of the mentioned
2. Select the right option.
Given the variables p, q are of char type and r, s, t are of int type
1. t = (r * s) / (r + s);
2. t = (p * q) / (r + s);
a) 1 is true but 2 is false
b) 1 is false and 2 is true
c) both 1 and 2 are true
d) both 1 and 2 are false
3. Which of the following belongs to the set of character types?
a) char
b) wchar_t
c) only a
d) both a and b
4. What will be the output of this program?
a) A
b) N
c) J
d) I
5. How do we represent a wide character of the form wchar_t?
a) L’a’
b) l’a’
c) L[a]
d) la
6. What is the output of this program?
a) Compiler error
b) 12
c) 10
d) Empty
7. In C++, what is the sign of character data type by default?
a) Signed
b) Unsigned
c) Implementation dependent
d) None of these
8. Is the size of character literals different in C and C++?
a) Implementation defined
b) Can’t say
c) Yes, they are different
d) No, they are not different
9. Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char) return?
a) 4
b) 1
c) Implementation dependent
d) Machine dependent
10. What constant defined in <climits> header returns the number of bits in a char?
a) CHAR_SIZE
b) SIZE_CHAR
c) BIT_CHAR
d) CHAR_BIT
a) 64
b) 128
c) 256
d) none of the mentioned
Answer:b
2. Select the right option.
Given the variables p, q are of char type and r, s, t are of int type
1. t = (r * s) / (r + s);
2. t = (p * q) / (r + s);
a) 1 is true but 2 is false
b) 1 is false and 2 is true
c) both 1 and 2 are true
d) both 1 and 2 are false
Answer:c
3. Which of the following belongs to the set of character types?
a) char
b) wchar_t
c) only a
d) both a and b
Answer:d
4. What will be the output of this program?
#include <iostream>
using namespace std;
int main()
{
char c = 74;
cout << c;
return 0;
}
b) N
c) J
d) I
Answer:c
5. How do we represent a wide character of the form wchar_t?
a) L’a’
b) l’a’
c) L[a]
d) la
Answer:a
6. What is the output of this program?
#include <stdio.h>
int main()
{
char a = '\012';
printf("%d", a);
return 0;
}
b) 12
c) 10
d) Empty
Answer:c
7. In C++, what is the sign of character data type by default?
a) Signed
b) Unsigned
c) Implementation dependent
d) None of these
Answer:c
8. Is the size of character literals different in C and C++?
a) Implementation defined
b) Can’t say
c) Yes, they are different
d) No, they are not different
Answer:c
9. Suppose in a hypothetical machine, the size of char is 32 bits. What would sizeof(char) return?
a) 4
b) 1
c) Implementation dependent
d) Machine dependent
Answer:b
10. What constant defined in <climits> header returns the number of bits in a char?
a) CHAR_SIZE
b) SIZE_CHAR
c) BIT_CHAR
d) CHAR_BIT
Answer:d