View Single Post
Old 03-03-2003, 06:22 PM   #1 (permalink)
ecox76
Registered User
 
ecox76's Avatar
 
Join Date: Mar 2003
Location: USA
Posts: 2
ecox76 is on a distinguished road
Send a message via Yahoo to ecox76
Question can someone please explain this to me

why does this code work, but if the main function is before the rest of them, it won't compile? i don't understand why "main" has to be on the bottom! very puzzling.

==============================
Code:
#include <iostream.h>

int one()
{
cout <<"you picked one!" <<endl;

return 0;
}

int two()
{
cout <<"you picked two!" <<endl;

return 0;
}

int three()
{
cout <<"you picked three!" <<endl;

return 0;
}


int main()
{
int pick;

cout <<"Pick 1,2, or 3: " <<endl;
cin >> pick;

        if (pick==1)
                {
                one();
                }
        if (pick==2)
                {
                two();
                }
        if (pick==3)
                {
                three();
                }

return 0;
}
===========================================
ecox76 is offline   Reply With Quote