Why is the output not what I want it to be

–1 vote
asked May 2 by Ivana Ogunlaja (610 points)
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string subject;
    cout << "What is your favourite subject";
    cin >> subject;
    cout << "Nice",subject, "is a good subject";
    return 0;
}

output

What is your favourite subject? input maths

output Nice

1 Answer

+1 vote
answered May 2 by LiOS (5,120 points)
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string subject;
    cout << "What is your favourite subject";
    cin >> subject;
    cout << "Nice " << subject << " is a good subject";
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...