-
if problems
sorry but i'm stuck again...heres my code
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout<<"Enter Your Name: ";
cin>> name;
if(name==Chris)
{
cout<<"welcome Chris";
}
else if(name==nick)
{
cout<<"welcome Nick";
}
return 0;
}
this isn't really what my programs gunna be i was just seeing if i could use the if statements...anyway. could someone tell me whats wrong i have like 4 errors with it.
-
Refugee
You forgot to put quotes around the names. This is what it should look like...
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout<<"Enter Your Name: ";
cin>> name;
if(name=="Chris")//Here are the missing quotes around Chris
{
cout<<"welcome Chris";
}
else if(name=="Nick") //Here are the missing quotes around Nick
{
cout<<"welcome Nick";
}
return 0;
}
-Chris (that's my name too!)
-