Call by Value and Call by Reference in C

| Last Updated: | In: C Programming Tutorial


In c programming language, there are two ways to pass the data to the function.

  1. Call by value
  2. Call by reference

In the call by value, the value is not modified but in the call by reference, the value is modified.

Difference between call by value and call by reference

Below is the difference between the call by value and call by reference. In the call by value, the actual arguments are passed to formal arguments so that the value is not modified, but in the call by reference, the address of actual arguments is passed to formal arguments and the value is modified.

What is call by value

Here is an example of the call by value.

Output

num1: 10
num2: 20

What is call by reference

Here is an example of the call by reference.

Output

n1: 20
n2: 10

Tags: , , , , ,