What will the output of the following questions:C++#include <bits/stdc++.h>using namespace std; int main(){ string a = "Hello"; string b = "World"; string c = b.append(a); cout << c << endl; return 0;}Hello worldWorld helloWorldHelloError
Question
What will the output of the following questions:C++#include <bits/stdc++.h>using namespace std; int main(){ string a = "Hello"; string b = "World"; string c = b.append(a); cout << c << endl; return 0;}Hello worldWorld helloWorldHelloError
🧐 Not the exact question you are looking for?Go ask a question
Solution
The output of the given C++ code will be "WorldHello".
Here's the step by step explanation:
- The string
ais initialized with the value "Hello". - The string
bis initialized with the value "World". - The
append()function is used to append the stringato the end of stringb. So,bbecomes "WorldHello". - The result of the
append()function is assigned to the stringc. So,calso becomes "WorldHello". - The value of
cis printed out, which is "WorldHello".
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.