Why is the output not what I want it to be

–2 votes
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

+2 votes
answered May 2 by LiOS (5,120 points)
selected May 3 by Ivana Ogunlaja
 
Best answer
#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;
}
commented May 2 by Vignesh Waran (100 points)
the answer for :
       What is your favourite subject Nice is a good subject
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.
...