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 two operators ++ and - work for the bool data type in C++?
- A. None
- B. ++
- C. -
- D. ++ & -
Correct Answer: B
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; }
- A. 012345
- B. 123456
- C. compile time error
- D. runtime error
Correct Answer: A
Which variable does equals in size with enum variable?
- A. int variable
- B. float variable
- C. string variable
- D. float & string variable
Correct Answer: A
Choose the incorrect option.
- A. void is used when the function does not return a value
- B. void is also used when the value of a pointer is null
- C. void is used as the base type for pointers to objects of unknown type
- D. void is a special fundamental type
Correct Answer: B
Identify the incorrect option.
- A. 1 <= sizeof(bool) <= sizeof(long)
- B. sizeof(float) <= sizeof(double) <= sizeof(long double)
- C. sizeof(char) <= sizeof(long) <=sizeof(wchar_t)
- D. sizeof(N) = sizeof(signed N) = sizeof(unsigned N)
Correct Answer: C
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; }
- A. 4
- B. 2
- C. 8
- D. garbage
Correct Answer: C
Which of these expressions will isolate the rightmost set bit?
- A. x = x & (~x)
- B. x = x ^ (~x)
- C. x = x & (-x)
- D. x = x ^ (-x)
Correct Answer: C
In C++, what is the sign of character data type by default?
- A. Signed
- B. Unsigned
- C. Implementation dependent
- D. Unsigned Implementation
Correct Answer: C
Which of the following statements are false?
- A. bool can have two values and can be used to express logical expressions
- B. bool cannot be used as the type of the result of the function
- C. bool can be converted into integers implicitly
- D. a bool value can be used in arithmetic expressions
Correct Answer: B
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; }
- A. 2 6
- B. 4 6
- C. 2 5
- D. 4 5
Correct Answer: D
Which of the following statements are true? int f(float)
- A. f is a function taking an argument of type int and returning a floating point number
- B. f is a function taking an argument of type float and returning an integer
- C. f is a function of type float
- D. f is a function of type int
Correct Answer: B
How do we represent a wide character of the form wchar_t?
- A. L'a'
- B. l'a'
- C. L[a]
- D. la
Correct Answer: A