How do you declare a multi-dimensional array (specifically, a 2D array) in C++?
int matrix[3, 4];
int matrix[3][4];
array matrix[3, 4];
int matrix(3)(4);
What will the following C++ code snippet print?
#include <iostream> void changeValue(int x) { x = 100; } int main() { int num = 50; changeValue(num); std::cout << num; return 0; }
100
None of the above
0
50
What is the correct way to declare an integer array named 'numbers' with a size of 5 in C++?
int numbers(5);
int numbers[5];
numbers[5] as int;
array numbers[5];
Which principle of OOP emphasizes hiding internal details and exposing only essential information?
Polymorphism
Encapsulation
Inheritance
Abstraction
Which keyword is used to achieve inheritance in C++?
inherits
extends
implements
colon (:)
Which C++ library provides functions for string manipulation, such as copying, concatenation, and comparison?
#include <array>
#include <cstring>
#include <iostream>
#include <string>
What is the purpose of the 'return' statement in a C++ function?
It terminates the function's execution and returns control to the calling function.
It declares a new variable within the function.
It prints the function's output to the console.
It marks a section of code for debugging purposes.
Which of these is NOT a benefit of using functions in programming?
Improved code organization
Increased memory usage
Easier debugging and maintenance
Code reusability
What is an inline function in C++?
A function that does not return any value.
A function that is declared with the 'inline' keyword, which serves as a request to the compiler to replace the function call with its actual code.
A function that takes another function as a parameter.
A function that is defined inside another function.
What is the correct way to declare a multi-line comment in C++?
// This is a multi-line comment
' This is a multi-line comment '
/* This is a multi-line comment */