//if and else
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string mystg;
int x;
cout << "Press 1 to talk about names. \n" << "press 2 to go talk about video games \n" << "Press 3 to go talk about school \n";
cin >> x;
}
if (x == 1) {
cout << "Welcome to the name talk. What is your name? \n ";
getline (cin, mystg);
cout << "Hello" << mystg << "Nice to meet you, my name is Alex. \n";
}
else if (x == 2) {
cout << "Welcome to the game talk, type in your favorite game please. \n";
getline (cin, mystg);
cout << mystg << " is a good game, but i think CoD is better. \n";
}
else if (x == 3) {
cout << "Welcome to the school chat, what is your favorite subject? \n";
getline (cin, mystg);
cout << "Nice, " << mystg << " thats a cool subject, my favorite is science. \n";
}
else {
cout << "Wrong number, type in either 1, 2, or 3.";
}
{
system ("pause");
return 0;
}
This is my first try on the if and else things and i thought i did good. but i keep getting that error in the title and it says i have the error right before the if or else if stuff. please help me and btw i just copied and pasted this from my dev-c++ so it looks different and more organized on the program, also i have just started coding 3 days ago and i am learning off of this site. Please help.
Umm if you can like tell me what to add and stuff that would be appreciative because i really dont know what like tags are and stuff because if you go to this website i have learned through what it is on http://www.cplusplus.com/doc/tutorial/control/