Character Types C++ MCQ

Errorlogger
0
1. How many characters are specified in the ASCII scheme?
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?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         char c = 74;
  6.         cout << c;
  7.         return 0;
  8.     }
a) A
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?
  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char a = '\012';
  5.  
  6.         printf("%d", a);
  7.         return 0;
  8.     }
a) Compiler error
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
Tags

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !