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.
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; }
- A. 323334
- B. 323232
- C. 323130
- D. 323134
Correct Answer: A
Which of three sizes of floating point types should be used when extended precision is required?
- A. float
- B. double
- C. long double
- D. extended float
Correct Answer: C
Identify the user-defined types from the following?
- A. enumeration
- B. classes
- C. both enumeration and classes
- D. int
Correct Answer: C
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; }
- A. 2035655065
- B. 2035655035
- C. 2035635065
- D. 2035645065
Correct Answer: A
Pick the right option. Statement 1: A definition is also a declaration. Statement 2: An identifier can be declared just once.
- 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: B
To which of these enumerators can be assigned?
- A. integer
- B. negative
- C. enumerator
- D. all of the mentioned
Correct Answer: D
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; }
- A. equal
- B. not equal
- C. compile time error
- D. runtime error
Correct Answer: A
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);
- A. 1 is true but 2 is false
- B. 1 is false and 2 is true
- C. both 1 and 2 are true
- D. both 1 and 2 are false
Correct Answer: C
Identify the type of variables. typedef char* CHAR; CHAR p,q;
- A. char*
- B. char
- C. CHAR
- D. unknown
Correct Answer: A
Which of the following is a valid floating-point literal?
- A. f287.333
- B. F287.333
- C. 287.e2
- D. 287.3.e2
Correct Answer: C
Which of these expressions will make the rightmost set bit zero in an input integer x?
- A. x = x | (x-1)
- B. x = x & (x-1)
- C. x = x | (x+1)
- D. x = x & (x+2)
Correct Answer: B
. . . . . . . . have the return type void.
- A. all functions
- B. constructors
- C. destructors
- D. none of the mentioned
Correct Answer: D