Which of the following accesses the third element of an integer array named 'data'?
data[2]
data.2
data[3]
data.third
What is the output of the following C++ code snippet?
#include <iostream> int main() { int arr[5] = {10, 20, 30, 40, 50}; std::cout << arr[3]; return 0; }
50
40
10
30
Which operator is used to access members of an object using a pointer to that object?
.
::
->
What is the correct way to receive user input in C++ and store it in a variable named 'name'?
scanf name;
input name;
cin >> name;
cout << name;
Which keyword is used to achieve inheritance in C++?
extends
inherits
colon (:)
implements
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 */
In C++, a character array can be used to store a string. What is the special character that signifies the end of a string in a character array?
\n
\0
'\0'
If 'ptr' points to the first element of an array, what does 'ptr + 1' point to?
The previous element in the array
The address of the array itself
The next element in the array
The size of the array
What is an inline function in C++?
A function that is defined inside another function.
A function that takes another function as a parameter.
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 does not return any value.
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
0
100