- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is call by reference in C language?
Pass by reference means addresses are sent as arguments.
The call by reference or pass by reference method passes the arguments to a function by the means of address to an argument. This is done into the formal parameter. Inside the function, the address is used to access an actual argument.
Example
#include<stdio.h> void main(){ void swap(int *,int *); int a,b; printf("enter 2 numbers"); scanf("%d%d",&a,&b); printf("Before swapping a=%d b=%d",a,b); swap(&a, &b); //address are sent as an argument printf("after swapping a=%d, b=%d",a,b); getch(); } void swap(int *a,int *b){ int t; t=*a; *a=*b; // *a = (*a + *b) – (*b = * a); *b=t; }
Output
When the above program is executed, it produces the following result −
enter 2 numbers 10 20 Before swapping a=10 b=20 After swapping a=20 b=10
- Related Articles
- What is pass by reference in C language?
- What is call by value in C language?
- Call by value and Call by reference in Java
- Difference between Call by Value and Call by Reference
- C++ Program to Swap Numbers in Cyclic Order Using Call by Reference
- Is JavaScript a pass-by-reference or pass-by-value language?
- What is pass by value in C language?
- How do I write a function with output parameters (call by reference) in Python?
- What is Pass By Reference and Pass By Value in PHP?
- What is the difference between pass by value and reference parameters in C#?
- What is a reference variable in C++?
- Passing by pointer Vs Passing by Reference in C++
- What is malloc in C language?
- What is Calloc in C language?
- What is Realloc in C language?

Advertisements