Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why is the output not what I want it to be

–1 vote
asked May 2, 2020 by Ivana Ogunlaja (640 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, 2020 by LiOS (6,420 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.
...