Question 14
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 = "x", b = "x", c = "x";
a += 65;
b += "65";
c += std::to_string(65);
std::cout << a << ' ' << b << ' ' << c << ' ' << a.size() << b.size() << '\n';
return 0;
}
- A xA x65 x65 23 Correct
- B x65 x65 x65 33
- C xA xA x65 22
- D x65 x65 xA 33
Correct Answer: Option A
The int 65 converts to the char 'A' and is appended as one character. "65" and to_string(65) append the two digit characters.
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!