c++ tutorials, c++ functions, c++ functions tutorial. c++ tutorials, c++ functions, c++ functions tutorial. About Us Contact Us

C++ Functions Tutorial


C++ Functions


We know that function play an important role in C program development. Dividing a program into functions is one of the major principles of top-down, structure programming.


Another advantage of using functions is that it is possible to reduce the size of a program by calling and using them at different places in the program


Example
void show ( ); /* Function declaration */
main ( )
{
………..
Show ( ); /* Function call */
………..
}
void show ( ) /* Function definition */
{
……….. /* Function body */
………..
………..
}

THE MAIN FUNCTION

C does not specify any return type for the main() function which is the starting point for the execution of a program. The definition of main() would look like this:

main ( )
{
	// main program statements
}


This is perfectly valid because the main () in C does not return any value.

In C++, the main() returns a value of type int to the operating system. C++, therefore, explicitly defines main() as matching one of the following prototypes:

int main();
int main(int args, char * argv []);

free online unix tutorial free online unix tutorial