MCQ Bank
In C/C++, the algebraic expression (b2-4ac) / 2a can be written as:
- A) b*b – 4* a*c / (2*a)
- B) b*b – (4*a*c) / 2*a
- C) b*b – 4*a* c/ 2*a
- D) (b*b – 4*a*c) / (2*a)
Which of the following C++ statements is used to show output on the screen?
- A) cerr
- B) cin
- C) cout
- D) cget
What will be the output of following program? #include <iostream> using namespace std; int main() { int x = 5; while (x > 0) { x--; } cout << "Final value of x: " << x << endl; return 0; }
- A) Final value of x: 0
- B) Final value of x: 5
- C) Final value of x: 6
- D) Final value of x: 2
Which of the following C++ statements is used take input from the user?
- A) cout
- B) cget
- C) cerr
- D) cin
A binary operator has _____ operands.
- A) Four
- B) Two
- C) One
- D) Three
The coding of a program is translated into machine language by ______.
- A) Linker
- B) Debugger
- C) Loader
- D) Compiler
Which of the following expression is correct in C/C++ language?
- A) X + 5 = Y + 7
- B) Y + X = 7
- C) X = X + 3
- D) 3 = X + 3
Which of the following is the correct way to initialize all the elements of array with 0?
- A) int arr[5]={5&0}
- B) int arr[5]={0};
- C) int arr[5]=All_Zero;
- D) int arr[5]={5(0)};
The size variable in the following program is a ______ variable. #include<iostream> … int size; … int main () { … }
- A) Static
- B) Local
- C) Constant
- D) Global
Two arrays are equal if ____________.
- A) Both their size and values are equal
- B) Only their values are equal
- C) Their values are equal but size is not
- D) Only their size is equal
Which of the following is the correct method to declare an array?
- A) array name [size] data type;
- B) data type array name [size];
- C) [size] array name data type;
- D) array name data type [size];
char name [] = “Hello World”; In the above statement, a memory of ____ characters will be allocated to the array name.
- A) 11
- B) 10
- C) 13
- D) 12
How do you access the element in the second row and third column of a 2D array named matrix?
- A) matrix[2][1]
- B) matrix{2, 3}
- C) matrix[2][3]
- D) matrix[1][2]
Which of the following two arrays are copy-able?
- A) int a[4], int b[5]
- B) float a[4], int b[5]
- C) int a[5], int b[5]
- D) int a[5], float b[5]
Which of the following is the default function calling mechanism of C/C++?
- A) Call by Function Memory
- B) Call by Reference
- C) Call by Variable Address
- D) Call by Value
What will be the output of the following code snippet? void func(int arr[]) { arr[0] = 10; } int main() { int arr[5] = {1, 2, 3, 4, 5}; func(arr); cout << arr[0]; return 0; }
- A) 2
- B) 1
- C) Undefined
- D) 10
In the call by reference method, which operator is used to get the address of a variable?
- A) %
- B) #
- C) &
- D) @
In C++, if we want to execute more than one statement within an ‘if statement’, then we have to enclose all statements in ______.
- A) <>
- B) {}
- C) []
- D) ()
Which of the following option is used when working with complicated expressions in C++ ?
- A) []
- B) /
- C) ()
- D) {}
What will be the output of the following code? int i = 1; while(i<10){ if (i % 2 == 0) cout << i << “ ”; i++; }
- A) 1 3 5 7
- B) 2 4 8 10
- C) 2 4 6 8
- D) 2 4 6 10