Which C++ library provides functions for string manipulation, such as copying, concatenation, and comparison?
#include <iostream>
#include <string>
#include <cstring>
#include <array>
What is the correct way to declare an integer array named 'numbers' with a size of 5 in C++?
numbers[5] as int;
array numbers[5];
int numbers(5);
int numbers[5];
Which of the following is NOT a valid way to initialize a character array in C++?
char message[5] = "Hello";
char message[10] = "Hello";
char message[] = "Hello";
char message[10] = {'H', 'e', 'l', 'l', 'o'};
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
What does the 'protected' access specifier in C++ control?
Accessibility within the same class only
Accessibility from anywhere in the program
Accessibility within the same class and derived classes
Accessibility only within the same file
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; }
Compilation Error
15
5
10
Why are pointers particularly useful when working with dynamic memory allocation?
Pointers allow us to directly access and manipulate memory addresses.
Pointers make our code run faster because they are low-level.
Pointers are required by the C++ syntax for dynamic memory allocation.
Pointers help us avoid using loops and conditional statements.
What does the modulus operator (%) return?
The sum of two operands.
The quotient of a division.
The product of two operands.
The remainder of a division.
What C++ function can you use to find the length of a C-style string (character array)?
size()
strlen()
str_length()
length()
What is a function signature in C++?
The comments and documentation associated with a function.
The value returned by the function.
The function's body (the code within the curly braces).
The function's name and the data types of its parameters.