Question 1
Back to Exercise
What is the output of the following C++ program on a 64-bit system?
#include <iostream>
#include <string>
int main() {
std::string a = "Learn", b = "C++";
std::string c = a + " " + b + '!';
a += b;
std::cout << c << ' ' << c.size() << ' ' << a << '\n';
return 0;
}
- A Learn C++! 10 LearnC++ Correct
- B Learn C++! 9 LearnC++
- C Learn C++! 10 Learn
- D LearnC++! 9 LearnC++
Correct Answer: Option A
"Learn" + " " + "C++" + '!' has 5 + 1 + 3 + 1 = 10 characters. += appends b to a in place.
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!