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
0
50
None of the above
Which statement is used to display output to the console in C++?
printf
print
cin
cout
Which of the following is NOT a valid C++ function definition?
void printMessage();
int sum(int a, int b) { return a + b; }
double calculateArea(double radius) { return 3.14 * radius * radius; }
string greet(string name) { cout << "Hello, " << name << "!" << endl; }
What does the modulus operator (%) return?
The quotient of a division.
The sum of two operands.
The remainder of a division.
The product of two operands.
Which of the following is NOT a type of inheritance in C++?
Distributed inheritance
Multilevel inheritance
Single inheritance
Multiple inheritance
What is a pure virtual function in C++?
A function that automatically destroys an object
A function with no implementation in the base class, meant to be overridden by derived classes
A function that creates new data types
A function that can be called before an object is created
Which operator is used to combine two strings in C++?
/
Which of the following loops in C++ guarantees that the loop body will execute at least once?
for loop
do-while loop
while loop
What is the concept of abstraction in OOP?
Hiding complex implementation details and exposing only essential information
Using virtual functions for polymorphism
Creating objects from a class
Implementing multiple inheritance
Which C++ library provides functions for string manipulation, such as copying, concatenation, and comparison?
#include <iostream>
#include <array>
#include <cstring>
#include <string>