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; }
None of the above
50
100
0
What will the following code snippet print?
int num = 10; while (num > 0) { num = num - 2; cout << num << " "; }
10 8 6 4 2 0
8 6 4 2 0
9 7 5 3 1
10 8 6 4 2
If 'func' is a function that takes an integer and returns void, how would you call this function using a pointer 'ptr' to the function?
*ptr(5);
&ptr(5);
ptr(5);
func(ptr, 5);
How can you prevent a C++ class from being inherited from?
By not defining any constructors
By making all its members private
By using the 'abstract' keyword
By declaring it with the 'final' keyword
What is an inline function in C++?
A function that is defined inside another function.
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.
What is the correct way to declare an integer array named 'numbers' with a size of 5 in C++?
int numbers[5];
array numbers[5];
numbers[5] as int;
int numbers(5);
Which operator is used to combine two strings in C++?
/
What is the correct way to receive user input in C++ and store it in a variable named 'name'?
input name;
scanf name;
cout << name;
cin >> name;
Which C++ library provides functions for string manipulation, such as copying, concatenation, and comparison?
#include <iostream>
#include <array>
#include <string>
#include <cstring>
What is the value of 'i' after the following loop completes?
int i; for (i = 0; i < 5; i++) { // Loop body }
4
5
6
Undefined behavior