Question 12
Back to Exercise
What is the output of the following program, compiled as C++23?
#include <iostream>
#include <string>
int main() {
std::string f = "report_2026.pdf";
std::cout << f.starts_with("rep") << f.starts_with('R') << f.ends_with(".pdf")
<< f.contains("2026") << f.contains('x') << '\n';
return 0;
}
- A 10110 Correct
- B 11110
- C 10111
- D 00110
Correct Answer: Option A
The checks are case-sensitive, so 'R' does not match 'r'. contains (C++23) accepts a string or a character.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!