MCQ Bank
Which type of arrays are used while dealing with sentences?
- A) Integer arrays
- B) Character arrays
- C) Word arrays
- D) Floating-point arrays
A variable declared inside a code block becomes the variable for that block.
- A) Constant
- B) Global
- C) Local
- D) Static
____ character is used to terminate a string.
- A) Null
- B) End
- C) Full
- D) Stop
In C++, the precise way to declare a pointer is.
- A) int ptr;
- B) int ptr*;
- C) int & ptr;
- D) int * ptr;
In C++, what is the correct syntax for accessing the fifth element of an array?
- A) a[4]
- B) a[5]
- C) a(5)
- D) a(4)
Which of the following shows the memory address of the first element in an array?
- A) array(0)
- B) array{0}
- C) array[0]
- D) array
In C++, all the string manipulation function are defined inside _______ header file.
- A) stdio.h
- B) conio.h
- C) string.h
- D) iostream
What will be the output of the following code? int main(){ int number[5] = {10,20,30,40,50}; cout << *(number+3); }
- A) 40
- B) 10
- C) 30
- D) 50
In C/C++ language, the subscript of array starts from ______.
- A) 3
- B) 2
- C) 0
- D) 1
From the following code, what will be the size of the array “name”? char name [] = “My full name”;
- A) 13
- B) 15
- C) 14
- D) 12
What will be the output of the following code? int main(){ char str1[] = “Hello ”; char str2[] = “World!”; cout << strcat(str1,str2); }
- A) Hello World!
- B) World!
- C) Hello
- D) HelloWorld!
In the syntax of the overloaded operator function given below: Complex operator + (Complex & ); What is ‘operator’?
- A) Object
- B) Operand
- C) Class
- D) Keyword
Which of the following is assignment operator?
- A) -
- B) =
- C) ^
- D) +
The correct syntax of stream insertion operator is:
- A) ostream* ostream::operator << ();
- B) istream& istream::operator >> (char *text);
- C) ostream& ostream::operator << (char *text);
- D) istream* istream::operator >> ();
What will be out put of following code: #include <iostream> #include <iomanip> using namespace std; main () { int num=7; cout << setfill('*') << setw(4) << num << endl; }
- A) ***7
- B) 7***
- C) 7****
- D) ****7
When overloading assignment (=) operator, which of the following syntax is correct?
- A) void operator = ( const String &s );
- B) void operator (= String &s );
- C) void operator (=) const String &other ;
- D) void operator (=) ( const String &s );
A variable of the bool data type can take ______ values.
- A) 2
- B) 0
- C) 3
- D) 1
Correct syntax of the prototype of the overloaded operator function is _____________.
- A) return-type operator operator-symbol (parameter-list);
- B) operator operator-symbol return type ( no parameter);
- C) return type operator-symbol operator (parameter);
- D) return type operator (operator-symbol)
if (day == daysOfMonth ( *this ) ) { } In above code, *this refers to:
- A) Any Object
- B) Current Object
- C) Today Date and Time
- D) Current Class
What will be the output of following code? #include <iostream> #include <iomanip> using namespace std; main () { float num=15.9999; cout << setprecision (2) << num; }
- A) 15.999
- B) 16
- C) 15
- D) 15.99