RE: Syntax errors will be the death of me!

  • From: "Joseph Lee" <joseph.lee22590@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 10 Jul 2010 19:45:10 -0700

Hi,
It was the output code that had this error. Although switch statement might
make sense because it is missing "default", which in this case would handle
student ranking code other than 1 through 4. In CPP:
cout << ranking; << endl;
Would produce the error, as opposed to either:
{
cout << ranking;
cout << endl;
}
Or
cout << ranking << endl;
Which both of them the compiler will accept.
Cheers,
Joseph

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex Hall
Sent: Saturday, July 10, 2010 7:41 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: Syntax errors will be the death of me!

Well, cpp is not my language, but you have a semicolon after the first
case in the switch, and I do not think it should be there.

On 7/10/10, Jes <theeternalkid@xxxxxxxxx> wrote:
> Hey guys,
> Here's a code for an assignment which has to be turned in tomorrow. Every
> time I try to compile it, Visual Studio keeps telling me I'm missing a ;
> before <<
> What's wrong?
> Code follows:
> //Ch6ConE06.cpp
> //Displays a class rank based on a code
> //entered by the user
> //Created/revised by <your name> on <current date>
>
> #include <iostream>
>
> using std::cout;
> using std::cin;
> using std::endl;
>
> int main()
> {     
>       //declare variable
>       int code = 0;
>
>       //enter input
>       cout << "Enter the code: ";
>       cin >> code;
> //enter switch statements
> switch(code)
> {
> case 1:;
> cout << "Freshman. " ; << endl;
> break;
> case 2:
>       cout <<"Sophomore"; << endl;
> break;
> case 3:
> cout << "Junior "; << endl;
> break;
> case 4:
> cout << "Senior" ; << endl;
> break;
> case 5:
> cout << "Error! "; << endl;
> }
> //endswitch
> //display output
>
>     return 0;
> }   //end of main function
>
> Jes
>
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.441 / Virus Database: 271.1.1/2992 - Release Date: 07/10/10
19:59:00

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: