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 following is not one of the sizes of the floating point types?

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

Which is correct with respect to the size of the data types?

  1. A. char > int < float
  2. B. int float
  3. C. char < int < float
  4. D. char < int < double
Report Error

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

  1. A. 20
  2. B. compile time error
  3. C. runtime error
  4. D. 40
Report Error

Is the size of character literals different in C and C++?

  1. A. Implementation defined
  2. B. Can't say
  3. C. Yes, they are different
  4. D. No, they are not different
Report Error

Can two functions declare variables(non static) with the same name?

  1. A. No
  2. B. Yes
  3. C. Yes, but not a very efficient way to write programs
  4. D. No, it gives a runtime error
Report Error

Pick the right option. Statement 1: Global values are not initialized by the stream. Statement 2: Local values are implicitly initialised to 0.

  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

Identify the incorrect statements. int var = 10; int *ptr = &(var + 1); //statement 1 int *ptr2 = &var; //statement 2 &&var = 40; //statement 3

  1. A. Statement 1 and 2 are wrong
  2. B. Statement 2 and 3 are wrong
  3. C. Statement 1 and 3 are wrong
  4. D. Statement 1, 2 and 3 are wrong
Report Error

For what values of the expression is an if-statement block not executed?

  1. A. 0 and all negative values
  2. B. 0 and -1
  3. C. 0
  4. D. 0, all negative values, all positive values except 1
Report Error

What will be the output of the following C++ code? #include using namespace std; enum cat { temp = 7 }; int main() { int age = 14; age /= temp; cout << "If you were cat, you would be " << age << endl; return 0; }

  1. A. If you were cat, you would be 5
  2. B. If you were cat, you would be 2
  3. C. If you were cat, you would be 7
  4. D. If you were cat, you would be 9
Report Error

Which of the following belongs to the set of character types?

  1. A. char
  2. B. wchar_t
  3. C. only a
  4. D. both wchar_t and char
Report Error

What is the range of the floating point numbers?

  1. A. -3.4E+38 to +3.4E+38
  2. B. -3.4E+38 to +3.4E+34
  3. C. -3.4E+38 to +3.4E+36
  4. D. -3.4E+38 to +3.4E+32
Report Error

What will be the output of the following C++ code? #include using namespace std; int main() { int i; enum month { JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC }; for (i = MAR; i <= NOV; i++) cout << i; return 0; }

  1. A. 01234567891011
  2. B. 123456789101112
  3. C. 34567891011
  4. D. 123456789
Report Error