Table of Contents
What is Call by value in C ?
In this type of function calling the actual value of an argument is passed to formal parameters of the function.
Once a function receives the value then it will start its operation, but this operation will never affect the argument.
Operation will be performed on values but it will not affect argument variables.
Argument value will remain unchanged even after the function’s execution.
Example of call by value in C
#include <stdio.h>
void swap(int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int main ()
{
int x = 5;
int y = 8;
printf("Value of x before swapping : %dn", x );
printf("Value of y before swapping : %dn", y );
swap(x,y);
printf("Value of x before swapping : %dn", x );
printf("Value of y before swapping : %dn", y );
return 0;
}
Output :
Value of a before swapping : 5
Value of b before swapping : 8
Value of a before swapping : 5
Value of b before swapping : 8
As we can see in the above output the function’s operation will not affect values of argument variables.
CHECKOUT OTHER RELATED TOPICS
CHECKOUT OTHER QUIZZES
Quizzes on Operator |
Easy Quiz on Operators in C part 1 |
Easy quiz on operators in C part 2 |
Easy quiz on operators in C part 3 |
Quizzes on Loops |
Easy quiz on loops in C part 1 |
Easy quiz on loops in C part 2 |
Easy quiz on loops in C part 3 |
Quizzes on Decision Making Statement |
Easy Quiz On Decision Making Statements Part 1 |
Easy Quiz On Decision Making Statements Part 2 |
Quizzes on String |
Easy quiz on String in C programming part 1 |
Quizzes on Array |
Easy quiz on Array in C programming – part 1 |
5 – Best Java program to convert decimal to binary |
New Quizzes Coming soon.. |
PRACTICALS IN C PROGRAM
We are aiming to explain all concepts of C in easiest terms as possible.

ITVoyagers
Author