Call by Value and Call by Reference in C

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

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

Article Tags: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Solved Programs