MCQ Bank
Macro is defined by ____________ preprocessor directive.
- A) #if
- B) #else
- C) #endif
- D) #define
Which is not a preprocessor directive of C-language?
- A) #endif
- B) #else
- C) #startif
- D) #if
What does the expression malloc(1000 * sizeof(int)) do?
- A) Allocates memory for 1000 integers
- B) Allocates memory for 1000 characters
- C) Allocates memory for 1000 floats
- D) Allocates memory for 1000 bytes
What would be the output of the following statement? c = 13 % 2;
- A) 2
- B) 3
- C) 1
- D) 0
The statement char arr [10]; is an example of a type of ____________ memory allocation.
- A) Null Value
- B) Dynamic
- C) Static
- D) Built-in
Dynamic memory allocation uses memory from the __________.
- A) Stack
- B) Mulit-dimensional Array
- C) Heap
- D) Array
Representing logical depiction of the solution to the problem is known as a ______________.
- A) Structure
- B) Sequence
- C) Loop
- D) Flowchart
Functions seekg () and seekp () require an argument of type ____ to let them know how many bytes to move forward or backward.
- A) long
- B) float
- C) double
- D) int
In C++, which operator is used while accessing through the pointer to structure?
- A) _
- B) &
- C) ->
- D) =
Dynamic memory allocation uses memory from the __________.
- A) Heap
- B) Mulit-dimensional Array
- C) Stack
- D) Array
In C++, the name of the _________ is the same as that of a class with a preceding tilde (~) sign.
- A) Destructor
- B) Friend function
- C) Constructor
- D) Utility function
A constructor with arguments is known as.
- A) Default Constructor
- B) Virtual Constructor
- C) Paramterized Constructor
- D) Destructor
Which of the following is a correct example of function overloading in C++?
- A) int sqrt(int i); int sqrt(double i);
- B) int sqrt(int i); double sqrt(int i);
- C) int sqrt(int i); double sqrt(double i);
- D) double sqrt(int i); float sqrt(int i);
In C++, combination of ________ and _________ functions are used to determine the actual data length of a file.
- A) seekg(), tellg()
- B) seekp(), tellp()
- C) getc(), putc()
- D) putc(), getc()
What is the purpose of using && in an if condition?
- A) To combine two conditions where both must be true
- B) To end the if block
- C) To check equality
- D) To combine two conditions where at least one must be true
What type of expression is used as the condition in a while loop?
- A) Logical expression (returns true or false)
- B) Integer expression
- C) Character expression
- D) String expression
What will be the output of the following code? void sampleFunction(int = 5,float = 4.1, char = 'A'); int main(){ sampleFunction(50,3.2); } void sampleFunction(int one,float two ,char three) { cout << one << ", " << two << ", " << three; }
- A) 5, 4.1, A
- B) 50, 4.1, A
- C) 50, 3.2, A
- D) 5, 3.2, A
_________ is a user-defined data type.
- A) Function
- B) Pointer
- C) Class
- D) Constructor
In C++, which operator is used to access the data members of the class?
- A) Not
- B) And
- C) Plus
- D) Dot
In C++, the default constructor takes _______.
- A) No arguments
- B) Only one argument
- C) More than two arguments
- D) Only two arguments