Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: stolsig55 on January 10, 2012, 04:36:26 am
-
Sorry if this come of as trivial, but while I am currently trying to learn code, I am frustrated by an error message that seems to make no sense.
I receive the error: 'else' without a previous 'if'
But there is an if right above the else.
cin >> drink;
if ( drink == 1 );
cout << "You selected Dr. Pepper. Thank you for completing the survey.";
else if (drink == 2);
cout << "you selected Sprite. Thank you for sompleting the survey.";
Help would be greatly appreciated
-
You are posting in the wrong forum! This forum is not meant for direct programming questions.
Try searching Google for "C++ forum".
However, your problem is this:
cin >> drink;
if ( drink == 1 );
cout << "You selected Dr. Pepper. Thank you for completing the survey.";
else if (drink == 2);
cout << "you selected Sprite. Thank you for sompleting the survey.";