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.

What will be the output of the following C++ code? #include using namespace std; enum test { A = 32, B, C }; int main() { cout << A << B<< C; return 0; }

  1. A. 323334
  2. B. 323232
  3. C. 323130
  4. D. 323134
Report Error

Which of three sizes of floating point types should be used when extended precision is required?

  1. A. float
  2. B. double
  3. C. long double
  4. D. extended float
Report Error

Identify the user-defined types from the following?

  1. A. enumeration
  2. B. classes
  3. C. both enumeration and classes
  4. D. int
Report Error

What will be the output of the following C++ code? #include using namespace std; int g = 100; int main() { int a; { int b; b = 20; a = 35; g = 65; cout << b << a << g; } a = 50; cout << a << g; return 0; }

  1. A. 2035655065
  2. B. 2035655035
  3. C. 2035635065
  4. D. 2035645065
Report Error

Pick the right option. Statement 1: A definition is also a declaration. Statement 2: An identifier can be declared just once.

  1. A. Statement 1 is true, Statement 2 is false
  2. B. Statement 2 is true, Statement 1 is false
  3. C. Both are false
  4. D. Both are true
Report Error

To which of these enumerators can be assigned?

  1. A. integer
  2. B. negative
  3. C. enumerator
  4. D. all of the mentioned
Report Error

What will be the output of the following C++ code? #include using namespace std; int main() { float f1 = 0.5; double f2 = 0.5; if (f1 == 0.5f) cout << "equal"; else cout << "not equal"; return 0; }

  1. A. equal
  2. B. not equal
  3. C. compile time error
  4. D. runtime error
Report Error

Given the variables p, q are of char type and r, s, t are of int type. Select the right statement? 1. t = (r * s) / (r + s); 2. t = (p * q) / (r + s);

  1. A. 1 is true but 2 is false
  2. B. 1 is false and 2 is true
  3. C. both 1 and 2 are true
  4. D. both 1 and 2 are false
Report Error

Identify the type of variables. typedef char* CHAR; CHAR p,q;

  1. A. char*
  2. B. char
  3. C. CHAR
  4. D. unknown
Report Error

Which of the following is a valid floating-point literal?

  1. A. f287.333
  2. B. F287.333
  3. C. 287.e2
  4. D. 287.3.e2
Report Error

Which of these expressions will make the rightmost set bit zero in an input integer x?

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

. . . . . . . . have the return type void.

  1. A. all functions
  2. B. constructors
  3. C. destructors
  4. D. none of the mentioned
Report Error