What is the output of the following code snippet?
int i = 10; do { cout << i << " "; i--; } while (i > 10);
9 8 7 6 5 4 3 2 1 0
The loop will run infinitely
10 9 8 7 6 5 4 3 2 1
10
What is the correct way to declare a constant variable named 'PI' with the value 3.14159?
constant PI = 3.14159;
const float PI 3.14159;
const float PI = 3.14159;
#define PI = 3.14159
How can you prevent a C++ class from being inherited from?
By making all its members private
By declaring it with the 'final' keyword
By using the 'abstract' keyword
By not defining any constructors
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
What is a function signature in C++?
The value returned by the function.
The comments and documentation associated with a function.
The function's name and the data types of its parameters.
The function's body (the code within the curly braces).
How do you declare a variable named 'age' of integer type?
int age;
declare age as integer;
age as int;
variable age: int;
Which of the following is NOT a valid C++ function definition?
string greet(string name) { cout << "Hello, " << name << "!" << endl; }
int sum(int a, int b) { return a + b; }
double calculateArea(double radius) { return 3.14 * radius * radius; }
void printMessage();
What is an inline function in C++?
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.
A function that does not return any value.
What C++ function can you use to find the length of a C-style string (character array)?
size()
strlen()
length()
str_length()
What is the output of the following C++ code snippet?
#include <iostream> int main() { int x = 5; int y = 10; int result = (x, y); std::cout << result; return 0; }
5
15
Compilation Error