In order for a function to be used in a program, it must be called. To do this, the name of the functio and any parameters you are passing to it must be typed out EXACTLY as how you declared it. The below example shows how to call as well as declare function.
Example 1:
Void example .
Below is a program that will show an example of a void function and how is called .
Example 1:
Void example .
Below is a program that will show an example of a void function and how is called .
As you will observe , when the main function is run , the printMessage () function is called and prints out the message . Remember the rule of void functions : they do not return a value.#include <iostream.h>
void printMessage( )
{
cout<<"Hallo and Welcome ! "<<endl;
]
int main ( )
{
printMessage () ;
return 0 ;
}
0 komentar:
Posting Komentar