Wednesday 11 April 2018

Passing Parameters of a function in C/C++


Parameters passing to function

Parameter passing to a function is a process of passing values from function call to the function header.
Example:

#include<conio.h>
#include<iostream.h>

void square_of_value(int); à function declaration

void main()
{
clrsrc();
int value = 0;
cout<< “ Enter a value: “ ;
cin>> value;                                                                   
square_of_value( value );  à function call
getch();                                                                               
}

void square_of_value(int num) à function header
{
cout << “square of the given number is: ”<< num ;
}

Actual parameter
Actual parameter is a parameter that is used in function call. It is passed to the function.

Formal parameter
A parameter used in function header is called as Formal parameter.

No comments:

Post a Comment