cannot run programme

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SATHYA JEEVA KANTH
    New Member
    • Mar 2008
    • 2

    cannot run programme

    i cannot run this programme can any one tell me why.
    [code=cpp]
    #include<iostre am.h>
    void main()
    {
    char grade;
    cout<<"pls key:";
    cin>>grade;
    switch(grade)
    {
    case 'a':
    cout<<"minimum is 30\n";
    break;
    case'b':
    cout<<"minimum is 20\n";
    break;
    default:
    cout<<"minimum is 10\n";
    }
    }[/code]
    Last edited by sicarie; Mar 22 '08, 02:20 PM. Reason: Code tags
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Did your compiler tell you why you couldn't?

    3 things you should do in your C++ programs:

    1) do not use the .h after iostream - it's depricated.
    2) main is an int, not a void, and you need a return type (standard is 0) at the end of the program.
    3) Specify/declare your namespace. For beginners, 'using namespace std;' will suffice after your library declarations.

    Your compiler might be complaining about these things, mine certainly allowed your code to compile and execute after I changed these things.
    Last edited by sicarie; Mar 22 '08, 02:24 PM. Reason: Update

    Comment

    Working...