What's wrong with this code guys?

#include <iostream>
#include <conio.h>
#include <cmath>
using namespace std;

int main()
{
    char 'A''B','C','D','E','F';
    int numbers;
    cout<<"Enter numbers"<<endl;
    cin>>numbers;
    if (numbers==90)
    {cout<<"Grade is A"}
    else if(numbers==80)    
    {cout<<"Grade is B"<<endl;}
    else if (numbers==70) 
    {cout<<"Grade is C"<<endl;}
    else if (numbers==60)
    {cout<<"Grade is D"<<endl;}
        else if(numbers < 60)
        {cout<<"Grade is F"<<endl;}
        else
        cout<<"Try again"<<endl;    
            getch();
            return 0;
    }   
Member Avatar for iamthwee

Removing the non-standard headerconio.hand removing getch()

And then compiling with the -pedantic switch I get:

x@x-Calistoga-ICH7M-Chipset:~/Documents/cpp$ g++ -Wall -pedantic blah.cpp
blah.cpp: In function ‘int main()’:
blah.cpp:7:10: error: expected unqualified-id before 'A'
blah.cpp:12:24: error: expected ‘;’ before ‘}’ token

For the following code:

#include <iostream>
//#include <conio.h>
#include <cmath>
using namespace std;
int main()
{
    char 'A''B','C','D','E','F';
    int numbers;
    cout<<"Enter numbers"<<endl;
    cin>>numbers;
    if (numbers==90)
    {cout<<"Grade is A"}
    else if(numbers==80)    
    {cout<<"Grade is B"<<endl;}
    else if (numbers==70) 
    {cout<<"Grade is C"<<endl;}
    else if (numbers==60)
    {cout<<"Grade is D"<<endl;}
        else if(numbers < 60)
        {cout<<"Grade is F"<<endl;}
        else
        cout<<"Try again"<<endl;    
           // getch();
            return 0;
    }  

That should give you a clue as to what you might start fixing.

First off you seem to want to declare some chars, but you're not giving any of them a name.

Secondly the cout statement on line 12 is missing the statement terminator ;

Thirdly none of the cout's will execute unless the number entered is exactly one of those grades, except for the last 2. you probably want to use >= instead of ==.

And when I use VC++ express , those syntax errors are highlighted for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.