Difference Between Call by Value and Call by Reference in C Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Functions can be invoked in two ways: Call by Value or Call by Reference. These two ways are generally differentiated by the type of values passed to them as parameters.The following table lists the differences between the call-by-value and call-by-reference methods of parameter passing.Call By ValueCall By ReferenceWhile calling a function, we pass the values of variables to it. Such functions are known as "Call By Values".While calling a function, instead of passing the values of variables, we pass the address of variables(location of variables) to the function known as "Call By References.In this method, the value of each variable in the calling function is copied into corresponding dummy variables of the called function.In this method, the address of actual variables in the calling function is copied into the dummy variables of the called function.With this method, the changes made to the dummy variables in the called function have no effect on the values of actual variables in the calling function.With this method, using addresses we would have access to the actual variables and hence we would be able to manipulate them.In call-by-values, we cannot alter the values of actual variables through function calls.In call by reference, we can alter the values of variables through function calls.Values of variables are passed by the Simple technique.Pointer variables are necessary to define to store the address values of variables.This method is preferred when we have to pass some small values that should not change.This method is preferred when we have to pass a large amount of data to the function.Call by value is considered safer as original data is preservedCall by reference is risky as it allows direct modification in original dataNote In C, we use pointers to achieve call-by-reference. In C++, we can either use pointers or references for pass-by-reference. In Java, primitive types are passed as values and non-primitive types are always references.Call By Value in CIn call by value method of parameter passing, the values of actual parameters are copied to the function’s formal parameters.There are two copies of parameters stored in different memory locations.One is the original copy and the other is the function copy.Any changes made inside functions are not reflected in the actual parameters of the caller.Example C #include <stdio.h> // Swap functions that swaps // two values void swapx(int x, int y) { int t; t = x; x = y; y = t; printf("Inside swapx: x = %d y = %d\n", x, y); } // Main function int main() { int a = 10, b = 20; // Pass by Values swapx(a, b); printf("Inside main: a = %d b = %d", a, b); return 0; } OutputInside swapx: x = 20 y = 10 Inside main: a = 10 b = 20Thus, actual values of a and b remain unchanged even after exchanging the values of x and y in the function.Call by Reference in CIn call by reference method of parameter passing, the address of the actual parameters is passed to the function as the formal parameters. In C, we use pointers to achieve call-by-reference.Both the actual and formal parameters refer to the same locations.Any changes made inside the function are actually reflected in the actual parameters of the caller.Example C #include <stdio.h> // Function to swap two variables // by references void swapx(int* x, int* y) { int t; t = *x; *x = *y; *y = t; printf("Inside swapx: x = %d y = %d\n", *x, *y); } int main() { int a = 10, b = 20; // Pass by reference swapx(&a, &b); printf("Inside main: a = %d b = %d", a, b); return 0; } OutputInside swapx: x = 20 y = 10 Inside main: a = 20 b = 10Thus, actual values of a and b get changed after exchanging values of x and y. Comment More infoAdvertise with us A AkshayGothe Follow Improve Article Tags : Difference Between C Language C-Pointers C-Functions Explore C Programming Language Tutorial 4 min read C BasicsC Language Introduction 6 min read Features of C Programming Language 3 min read C Programming Language Standard 6 min read C Hello World Program 1 min read Compiling a C Program: Behind the Scenes 4 min read C Comments 3 min read Tokens in C 4 min read Keywords in C 2 min read C Variables and ConstantsC Variables 4 min read Constants in C 4 min read Const Qualifier in C 6 min read Different ways to declare variable as constant in C 2 min read Scope rules in C 5 min read Internal Linkage and External Linkage in C 4 min read Global Variables in C 3 min read C Data TypesData Types in C 5 min read Literals in C 4 min read Escape Sequence in C 5 min read bool in C 5 min read Integer Promotions in C 2 min read Character Arithmetic in C 2 min read Type Conversion in C 4 min read C Input/OutputBasic Input and Output in C 4 min read Format Specifiers in C 5 min read printf in C 5 min read scanf in C 3 min read Scansets in C 2 min read Formatted and Unformatted Input/Output in C 6 min read C OperatorsOperators in C 11 min read Arithmetic Operators in C 5 min read Unary Operators in C 5 min read Relational Operators in C 4 min read Bitwise Operators in C 6 min read C Logical Operators 4 min read Assignment Operators in C 4 min read Increment and Decrement Operators in C 4 min read Conditional or Ternary Operator (?:) in C 3 min read sizeof operator in C 3 min read Operator Precedence and Associativity in C 7 min read C Control Statements Decision-MakingDecision Making in C (if , if..else, Nested if, if-else-if ) 7 min read C - if Statement 4 min read C if else Statement 3 min read C if , else if ladder 4 min read Switch Statement in C 5 min read Using Range in switch Case in C 2 min read C - Loops 6 min read C for Loop 4 min read while Loop in C 5 min read do...while Loop in C 4 min read For vs. While 4 min read Continue Statement in C 4 min read Break Statement in C 5 min read goto Statement in C 4 min read C FunctionsC Functions 6 min read User-Defined Function in C 6 min read Parameter Passing Techniques in C 3 min read Function Prototype in C 4 min read How can I return multiple values from a function? 3 min read main Function in C 5 min read Implicit Return Type int in C 2 min read Callbacks in C 4 min read Nested Functions in C 4 min read Variadic Functions in C 5 min read _Noreturn function specifier in C 2 min read Predefined Identifier __func__ in C 2 min read C Library math.h Functions 6 min read C Arrays & StringsC Arrays 7 min read Properties of Array in C 7 min read Multidimensional Arrays in C - 2D and 3D Arrays 8 min read Initialization of Multidimensional Array in C 4 min read Pass Array to Functions in C 3 min read How to pass a 2D array as a parameter in C? 3 min read What are the data types for which it is not possible to create an array? 2 min read How to pass an array by value in C ? 2 min read Strings in C 6 min read Array of Strings in C 3 min read What is the difference between single quoted and double quoted declaration of char array? 2 min read C String Functions 6 min read C PointersC Pointers 9 min read Pointer Arithmetics in C with Examples 10 min read C - Pointer to Pointer (Double Pointer) 5 min read Function Pointer in C 6 min read How to Declare a Pointer to a Function? 2 min read Pointer to an Array | Array Pointer 5 min read Difference between constant pointer, pointers to constant, and constant pointers to constants 3 min read Pointer vs Array in C 1 min read Dangling, Void , Null and Wild Pointers in C 6 min read Near, Far and Huge Pointers in C 4 min read restrict Keyword in C 3 min read Like