What is Function?


Function is a group of logically related statements that is used to perform specific task.
Function offers several advantages to the programmer:
There is no need to write same block of statements again and again. Thus it will reduce the length of the program.
Error handling is easy because we have to check only function body instead of same block of statement again and again.

     

main () Function in C++


The main function is the starting point for the execution of the program. The execution of every c++ program starts from main function.
The general syntax of main function in c++ is given below:
int main ()
Here,
main
function returns the value of type integer while in C main function does not return any value.
Hence main function in C++ returns value of type integer we must have to use return statement at the end of main function as shown below:

int main()
{
Block of statements
return 0;
}

If you don’t specify the return type for main function then default return type is considered of type integer.

Download Projects


Download Programs