Knowee
Questions
Features
Study Tools

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:

  1. The string a is initialized with the value "Hello".
  2. The string b is initialized with the value "World".
  3. The append() function is used to append the string a to the end of string b. So, b becomes "WorldHello".
  4. The result of the append() function is assigned to the string c. So, c also becomes "WorldHello".
  5. The value of c is printed out, which is "WorldHello".

This problem has been solved

Similar Questions

What will be the output of the following C code?

what will be the output of the c program?

What will be the output of the following program?

What will be the output of the C program? ans.1  88  82  21  1 Previous Marked for Review Next

What will be the output of the following code?

1/4

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.