If 'ptr' points to the first element of an array, what does 'ptr + 1' point to?
The address of the array itself
The previous element in the array
The size of the array
The next element in the array
Can a function in C++ return multiple values?
No, a C++ function can only return a single value.
Yes, using multiple 'return' statements.
Yes, by returning a container like a vector or an array.
Yes, by using references or pointers as parameters.
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 marks a section of code for debugging purposes.
It declares a new variable within the function.
It prints the function's output to the console.
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?
'\0'
\0
\n
.
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 '
Which principle of OOP emphasizes hiding internal details and exposing only essential information?
Abstraction
Polymorphism
Encapsulation
Inheritance
Which of the following is NOT a valid way to initialize a character array in C++?
char message[5] = "Hello";
char message[] = "Hello";
char message[10] = {'H', 'e', 'l', 'l', 'o'};
char message[10] = "Hello";
Which statement is used to display output to the console in C++?
printf
cin
cout
print
What will the following code snippet print?
int num = 10; while (num > 0) { num = num - 2; cout << num << " "; }
10 8 6 4 2
8 6 4 2 0
9 7 5 3 1
10 8 6 4 2 0
What is the output of the following code snippet?
int arr[] = {10, 20, 30}; int *ptr = arr; cout << *(ptr + 2);
20
10
30
Invalid memory access