Commerce

Variables And Data Types In C Plus Plus MCQs

Practice Variables And Data Types In C Plus Plus MCQs for competitive exams.

Variables And Data Types In C Plus Plus MCQs

Practice questions from this topic.

Which of the two operators ++ and - work for the bool data type in C++?

  1. A. None
  2. B. ++
  3. C. -
  4. D. ++ & -
Report Error

What will be the output of the following C++ code? #include using namespace std; enum colour { green, red, blue, white, yellow, pink }; int main() { cout << green<< red<< blue<< white<< yellow<< pink; return 0; }

  1. A. 012345
  2. B. 123456
  3. C. compile time error
  4. D. runtime error
Report Error

Which variable does equals in size with enum variable?

  1. A. int variable
  2. B. float variable
  3. C. string variable
  4. D. float & string variable
Report Error

Choose the incorrect option.

  1. A. void is used when the function does not return a value
  2. B. void is also used when the value of a pointer is null
  3. C. void is used as the base type for pointers to objects of unknown type
  4. D. void is a special fundamental type
Report Error

Identify the incorrect option.

  1. A. 1 <= sizeof(bool) <= sizeof(long)
  2. B. sizeof(float) <= sizeof(double) <= sizeof(long double)
  3. C. sizeof(char) <= sizeof(long) <=sizeof(wchar_t)
  4. D. sizeof(N) = sizeof(signed N) = sizeof(unsigned N)
Report Error

What will be the output of the following C++ code? #include using namespace std; int main ( ) { static double i; i = 20; cout << sizeof(i); return 0; }

  1. A. 4
  2. B. 2
  3. C. 8
  4. D. garbage
Report Error

Which of these expressions will isolate the rightmost set bit?

  1. A. x = x & (~x)
  2. B. x = x ^ (~x)
  3. C. x = x & (-x)
  4. D. x = x ^ (-x)
Report Error

In C++, what is the sign of character data type by default?

  1. A. Signed
  2. B. Unsigned
  3. C. Implementation dependent
  4. D. Unsigned Implementation
Report Error

Which of the following statements are false?

  1. A. bool can have two values and can be used to express logical expressions
  2. B. bool cannot be used as the type of the result of the function
  3. C. bool can be converted into integers implicitly
  4. D. a bool value can be used in arithmetic expressions
Report Error

What will be the output of the following C++ code? #include using namespace std; int main() { int a = 5; float b; cout << sizeof(++a + b); cout << a; return 0; }

  1. A. 2 6
  2. B. 4 6
  3. C. 2 5
  4. D. 4 5
Report Error

Which of the following statements are true? int f(float)

  1. A. f is a function taking an argument of type int and returning a floating point number
  2. B. f is a function taking an argument of type float and returning an integer
  3. C. f is a function of type float
  4. D. f is a function of type int
Report Error

How do we represent a wide character of the form wchar_t?

  1. A. L'a'
  2. B. l'a'
  3. C. L[a]
  4. D. la
Report Error