if else statements

Hey all.

I'm trying out strings and I wanted to add an if else statement to it. Here is my code so far. I have no idea how to include if else, so I haven't done it yet.

#include <iostream>
#include <conio.h>
using namespace std;
#include <windows.h>
#include <string>
#include <stdio.h>

int main()
{
string team;
cout << "What's your name?";
getline (cin, team);
cout << "Hello, " << team << ".\n";
Sleep(2300);
cout << "What is your favourite soccer team?\n";
getline (cin, team);
cout << team << " is a great team!\n";
Sleep(2800);
cout << "Are they in first place? Answer yes or no.";
_getch();
}

Now, after the cout << "Are they in first place?"; line, I want to add an if else statement to basically say if the user says "yes" to write "That's great!" and if the user says no, I want it to say "Oh, I'm sorry to hear that!"

Any help would be much appreciated.

Thanks!
http://cplusplus.com/doc/tutorial/control/

so in your case it would be
1
2
3
4
5
6
cin >> input; //with input beeing a std::string
if (input == "yes") {
    cout << "That's great!" << endl;
} else {
     cout << "Oh, I'm sorry to hear that!" << endl;
}
It says "input" is undefined.. Is there a header for that?
Last edited on
Mathes wrote:
//with input being a std::string
That means nothing to me. I've been programming for 3 days.
Ah, I got it. Thanks a lot guys!
Topic archived. No new replies allowed.