CommerceVariables 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?
- A. short float
- B. float
- C. long double
- D. double
Correct Answer: A
Which is correct with respect to the size of the data types?
- A. char > int < float
- B. int float
- C. char < int < float
- D. char < int < double
Correct Answer: D
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; }
- A. 20
- B. compile time error
- C. runtime error
- D. 40
Correct Answer: B
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
Correct Answer: C
Can two functions declare variables(non static) with the same name?
- A. No
- B. Yes
- C. Yes, but not a very efficient way to write programs
- D. No, it gives a runtime error
Correct Answer: C
Pick the right option. Statement 1: Global values are not initialized by the stream. Statement 2: Local values are implicitly initialised to 0.
- A. Statement 1 is true, Statement 2 is false
- B. Statement 2 is true, Statement 1 is false
- C. Both are false
- D. Both are true
Correct Answer: C
Identify the incorrect statements. int var = 10; int *ptr = &(var + 1); //statement 1 int *ptr2 = &var; //statement 2 &&var = 40; //statement 3
- A. Statement 1 and 2 are wrong
- B. Statement 2 and 3 are wrong
- C. Statement 1 and 3 are wrong
- D. Statement 1, 2 and 3 are wrong
Correct Answer: C
For what values of the expression is an if-statement block not executed?
- A. 0 and all negative values
- B. 0 and -1
- C. 0
- D. 0, all negative values, all positive values except 1
Correct Answer: C
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; }
- A. If you were cat, you would be 5
- B. If you were cat, you would be 2
- C. If you were cat, you would be 7
- D. If you were cat, you would be 9
Correct Answer: B
Which of the following belongs to the set of character types?
- A. char
- B. wchar_t
- C. only a
- D. both wchar_t and char
Correct Answer: D
What is the range of the floating point numbers?
- A. -3.4E+38 to +3.4E+38
- B. -3.4E+38 to +3.4E+34
- C. -3.4E+38 to +3.4E+36
- D. -3.4E+38 to +3.4E+32
Correct Answer: A
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; }
- A. 01234567891011
- B. 123456789101112
- C. 34567891011
- D. 123456789
Correct Answer: C