Calling a Function:
Executing the statements of a function to perform a task is called calling of the function. A function is called by referencing its name. The parameters (if any) of the function are given in parentheses after the name of the function. If a function has no parameters then the parentheses are left blank. If a function has a return value of numeric type then it can he used or called in an arithmetic expression.
When a function is called, the control shifts to the function definition and the statements in the body of the function are executed. After executing the statements in the body of the function, the control returns to the calling function and the next statement that comes immediately after the function call statement is executed.
Program:
Write a program to print a message on the screen using a function.
#include <iostream.h>
#include <conio.h>
main( )
{
void display (void);
clrscr( );
display( );
cout << “Ok”;
}
void display (void)
{
cout << “It is my first function program” <<endl;
}
comment closed