Exit Status In C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PAK11
    New Member
    • Mar 2008
    • 11

    Exit Status In C++

    Hello everyone I am having trouble figuring out what is wrong with my program. When I compile the message says "undefined reference to 'WinMain@16' collect2: Id returned 1 exit status". Im not sure if it is because I am running a void function or it could quite possibly be something else. Please Help Im Stuck!
    Here is my program.
    [code=cpp]
    void displayAverage( )
    {
    double total=0.0; //accumulator variable
    double avg=0.0; //average score
    double GPA[15]={0.0,0.0,0.0,0 .0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0 ,0.0,0.0,0.0,0. 0};

    for (int x=0; x<15; x+=1)//user inputs GPA's & accumulate GPA
    {
    cout<<"Please enter the GPA"<<endl;
    cin>>GPA[x];
    total=total+GPA[x];
    }//endfor

    //calculate avg GPA
    avg=total/15.0;
    cout<<"The average GPA is: "<<avg<<end l;

    //compare avg GPA to individual GPA
    for (int x=0; x<15; x+=1)
    {
    if(GPA[x]>avg)
    cout<<GPA[x]<<"is above the average"<<endl;
    else
    if(GPA[x]<avg)
    cout<<GPA[x]<<"is below the average"<<endl;
    else
    cout<<GPA[x]<<"equals the average"<<endl;
    }//end for

    return;
    }[/code]
    Last edited by sicarie; Apr 24 '08, 01:29 PM. Reason: Code tags are [code=cpp] and after your code [/code]. Please use them. They want to be used. They like to be used.
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Where is the main function in your code?
    The error is becos of missing main in your code

    raghuram

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      You probably created a Win32 project and when the wizard appeared, you clicked Finish. Now you have a Windows program when you want a console program.

      Either:
      1) Go to Project Properties - C/C++ - Linker - System and change the SubSystem property to Console

      Or:
      2) Recreate the project and when the wizard appears do not click finish. Instead, click application settings and select Empty Application and Console. Then click finish.

      Comment

      Working...