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.

MY Program do-sent work it wont say my what i want it to say it says hi instead of hi im bob

0 votes
asked May 9, 2018 by Eveldun 123 (180 points)
the output is hi not hi im bob

can you fix this

#include <iostream>
#include <string>
using namespace std;

int main()
{
string PW;
string error = "SYNTAX ERROR";

cout<<"hi"<< endl;
cin >> PW;

cout<<"im bob";

}

1 Answer

0 votes
answered May 10, 2018 by Simao Antunes (180 points)

Hello! You should write:


#include <iostream>
#include <stdlib.h>
using namespace std;


int main()
{
    string name;
    
    cout << "What is your name?" << endl;
    cin >> name;
    
    cout << "Hi, I am " << name;
}


It will ask your name and say "Hi" and your name after. Please tell me if there is anything wrong.

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.
...