3
Contributors
2
Replies
23
Views
3 Years
Discussion Span
Last Post by ArashVenus
0

If you mean how can you divide a program into functions and use the functions ,
there are 2 ways you can do It ,
1-writing the functions before main ,
2-writing them after main , and predeclaring them above main .

first one is simple , you write functions above main like this :

type function1 (inputs)
{
    statements and code;
}

type function2 (inputs)
{
    statements and code;
}

...

int main ()
{
    function1(inputs);
    function2(inputs);
    ...
    return 0;
}

second one is written like this :

type function1 (inputs);
type function2 (inputs);
...
int main 
{
    function1(inputs);
    function2(inputs);
    ...
    return 0;
}


type function1 (inputs)
{
    statements and code;
}

type function2 (inputs)
{
    statements and code;
}

...

ps : I prefer the first one .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.