1. During which phase is the program loaded into memory?
a. Compile
b. Link
c. Load
d. Execute
2. In C++, what kind of files are produced by the compiler before the linking stage?
A) Executable files
B) Object files
C) Header files
D) Source files
3. When does a compiler or interpreter typically detect syntax errors in a program?
A) During execution
B) During debugging
C) During compilation
D) During planning
4. What is a key characteristic of compiled languages?
a. Code is executed line by line.
b. The entire source code is translated into machine code before execution.
c. Portability is a major advantage.
d. Debugging is typically done interactively.
5. Which programming language is often cited as an example of a compiled language?
a. Python
b. Java
c. C++
d. JavaScript
6. Which of the following accurately describes the purpose of a union in C++?
a. Groups related variables under a single name
b. Allows the creation of named integral constants
c. Shares the same memory location for all its members
d. Defines a collection of elements
7. Which of the following is a primary (fundamental) data type in C++?
a. Array
b. Structure
c. Pointer
d. Long Double
8. What is the purpose of the following typedef declaration?
typedef unsigned long long int ULLI;
a. It defines a new struct named ULLI.
b. It creates an alias for unsigned long long int called ULLI.
c. It declares a union named ULLI.
d. It specifies a set of named integer constants.
9. In which type does the enumerators are stored by the compiler?
A. string
B. integer
C. float
D. none of the mentioned
10. What are the values of a, b, and c after this code executes?
int a = 5, b = 10, c;
c = a++ + --b
A) a=5, b=10, c=15
B) a=6, b=9, c=15
C) a=6, b=10, c=16
D) a=5, b=9, c=14
E) None of the mentioned
11. Which statement results from this code?
bool x = true, y = false;
bool z = x & y;
A) Error
B) z = true
C) z = false
D) None
12. In the switch statement, what is the purpose of the break keyword?
a. To terminate the program.
b. To move to the next case.
c. To exit the loop.
d. To prevent fall-through to subsequent cases.
13. In a for loop, what happens if the update expression is omitted?
a. It results in a compilation error.
b. The loop will not terminate.
c. The loop will not be executed
d. None
14. What happens if the condition of a do-while loop is always false?
a. The loop executes once.
b. The loop does not execute.
c. The loop becomes an infinite loop.
d. The loop causes a compilation error
20. What are mandatory parts in the function declaration?
a) return type, function name
b) return type, function name, parameters
c) parameters, function name
d) parameters, variables
21. How are many minimum numbers of functions need to be presented in c++?
A. 0
B. 1
C. 2
D. 3
22. Function declaration is omitted when function is defined ___________ main() function.
A) Inside
B) Before
C) After
D) Anywhere
23. What is the purpose of the following code?
int main() {
int x;
cout << "Enter a number between 1 and 100: ";
while (true) {
cin >> x;
if (x >= 1 && x <= 100) {
break;
} else {
cout<< "Invalid input.."
}
a. It checks if the entered number is between 1 and 100 (inclusive) and continues
execution.
b. It continues to prompt the user until a valid number is entered.
c. It prints an error message and exits if the entered number is not between 1 and 100.
d. It ignores the user input and exits the program.
24. What is concept of function overloading in C++.
A) Function overloading is a feature in C++ that allows defining multiple functions with the
same name but different return types.
B) Function overloading is a technique in C++ that allows defining multiple functions with
the same name but different numbers or types of parameters.
C) Function overloading is a practice in C++ that involves overwriting existing functions
with new functionality.
D) Function overloading is a way to create functions inside other functions to achieve better
code organization.
25. What is the main purpose of a base case in a recursive function?
a. To make the function call itself
b. To provide an exit condition and stop the recursion
c. To increase the efficiency of the recursive function
d. To make the function tail-recursive
26. Which of the following is a potential issue with recursive solutions in terms of efficiency and
memory usage?
a. Recursive functions are always more memory-efficient.
b. Recursive functions consume additional memory for each function call, potentially leading
to a stack overflow.
c. Recursive functions are faster than their iterative counterparts.
d. Recursive functions do not have any efficiency or memory-related concerns.
27. Where should default parameters appear in a function prototype?
a) To the rightmost side of the parameter list
b) To the leftmost side of the parameter list
c) Anywhere inside the parameter list
d) Middle of the parameter list
28. By default, all the files are opened in ___________mode .
a. Binary
b. Text
c. Both
d. None
29. Which stream class is to only write on files?
a) ofstream
b) ifstream
c) iostream
d) fstream
30. If we have object from ofstream class, then default mode of opening the file is _____ .
a. ios::in
b. ios::out
c. ios::in|ios::trunc
d. ios::out|ios::trunk
31. Which of the following is not used to seek file pointer?
a) ios::set
b) ios::end
c) ios::cur
d) ios::beg
32. When using the seekp() function with ios::cur as the offset, what does it do?
A. Sets the get pointer to the current position
B. Moves the put pointer relative to the end of the file
C. Moves the put pointer relative to the current position
D. Sets the put pointer to the beginning of the file
33. What will be printed by this code segment?
int x = 5;
while (x <= 10) {
if (x == 7)
continue;
cout << x << " ";
x++;
}
A) 5 6 7 8 9 10 C) 5 6 8 9 10 11
B) 5 6 8 9 10 D) Infinite loop E) none