News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Confusing error

Started by stolsig55, January 10, 2012, 04:36:26 AM

Previous topic - Next topic

stolsig55

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

Alpha

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.";