# NIOS Computer Science: Chapter 12 – Function Part 8

Glide to success with Doorsteptutor material for UGC : Get full length tests using official NTA interface: all topics with exact weightage, real exam experience, detailed analytics, comparison and rankings, & questions with full solutions.

Download PDF of This Page (Size: 296K) ↧

### VI. Calling of Function

The function can be called using either of the following methods:

#### Call-by-Value

Consider the following program which will swap the value of two variables using the method call-by-value.

# include < iostream.h>

void swap (int, int);

void main ( )

{

int a, b;

cin > > a > > b;

swap (a, b);

cout < < a < < b < < “\n”;

}

void swap (int c, int d)

{

int t;

t = c;

c = d;

d = t;

cout < < c < < d < < “\n”;

}

The variables a and b are called actual parameters.

When calling the function swap ( ). the value of a is passed onto c and value of b is passed onto d.

Here c and d are called formal parameters.

In the function swap ( ), the value are swapped but this change will not be implemented to actual parameters.

Input 5 6

Input 6 5

5 6