Author Topic: Can someone help me with basic C++?  (Read 738 times)

nopyo

  • 68 Carbine
  • Posts: 281
Can someone help me with basic C++?
« on: May 24, 2008, 01:21:06 PM »
I'm just starting to learn C++ in school and my current assignment is to make a one-question quiz program. I was wondering if someone can help me debug it. Here's the code and error message:

Code: [Select]
#include <iostream>

int main()
{

        int guess;
        int answer;

        answer=3;

        cout<< "\fWhich one of the choices is laughing the hardest?" <<endl;
        cout<< "1) rofl" <<endl;
        cout<< "2) jeje" <<endl;
        cout<< "3) roflmao" <<endl;
        cout<< "4) lol" <<endl;
        cout<< "Enter the NUMBER of your choice" <<endl;

        cin>> guess;

        while (guess!= answer)
        {
        cout<< "No, try again"<<endl;

        if (guess==1)
                {
                cout<< "Look for something more" <<endl;
                }
        if (guess==2)
                {
                cout<< "Think what sound a \"J\" makes in Spanish" <<endl;
        if (guess==4)
                {
                cout<< "Just a chuckle makes a sound, the \"out loud\" doesn't really mean anything extra" <<endl;
                }
        if (guess>4)
                {
                cout<< "Excuse me, but can you count from 1 to 4 ?" <<endl;
                }
        if (guess<1)
                {
                cout<< "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!!!!!!!!" <<endl;
                }

        cin>> guess;

        }

        cout<< "Correct :D" <<endl;

        cout<< "\n" <<endl;

        return 0;
}

Error message:
Code: [Select]
quiz.cpp: In function `int main()':
quiz.cpp:51: syntax error at end of input

Line 51 is after the entire code (after the very last "}" ), that's what I'm having trouble with.

I'll appreciate any help I can get.

y00tz

  • Autococker
  • Posts: 2742
Re: Can someone help me with basic C++?
« Reply #1 on: May 24, 2008, 01:28:28 PM »
Guess 2 needs a closing bracket.

nopyo

  • 68 Carbine
  • Posts: 281
Re: Can someone help me with basic C++?
« Reply #2 on: May 24, 2008, 02:00:01 PM »
*bangs head on table*

Thanks y00tz :)

:::Thread locked:::