Ok well, for a project I have to make a program that asks you questions. It's very simple. I ran into a problem; I made a char named "country" and I "made" it so it will ask "Where do you live" and if you say "Costa Rica" it will say "You live in Costa Rica! I do too", and if you say anything else it will say "You live in _____! I live in Costa Rica". Boom. simple right. nope. No matter what I type it will trigger "else". Please help!
#include <iostream>
#include <stdio.h>
#include <string>
#ifdef __WIN32__
#include <windows.h>
#else
#include <unistd.h>
#endif
usingnamespace std;
int main(void)
{
cout<<"Hi!\n";
Sleep(300);
string name;
cout<<"What is Your name?\n";
getline(cin, name);
cout<<"Well hello "<<name<<" nice to meet you"<<endl;
Sleep(800);
string age;
cout<<"How old are you?";
cout<<endl;
getline(cin, age);
Sleep(800);
cout<<"Oh you are "<<age<<" That's neat\n";
cout<<"Let me ask you a question\n";
Sleep(400);
int MQ;
cout<<"What's 3 plus 5?\n";
cin>>MQ;
if (MQ == 8)
{
cout<<"Your'e right! "<<MQ<<" Is the right answer!\n";
}
elseif (MQ > 8)
{
cout<<MQ<<" is too high!\n";
}
else
{
cout<<MQ<<" is too low\n";
}
char country[256];
cout<<"OK well, Where do you live?\n";
cin>>country;
if (country == "Costa Rica")
{
cout<<"You live in "<<country<<", I do too!\n";
}
else
{
cout<<"You live in "<<country<<", I live in Costa Rica\n";
}
}