What is call by value in C language?

Pass by value or call by value are sent as arguments.


Refer to the algorithm for the call by value.

Step 1: Enter any 2 numbers at runtime
Step 2: Read those two numbers from console
Step 3: Call the function swap with arguments is a call by value
Step 4: Go to called function
        swap(int a,int b)
Step 5: Print the numbers after swap


Following is the C program for the call by value −

void main(){
   void swap(int,int);
   int a,b;
   printf("enter 2 numbers");
   printf("Before swapping a=%d b=%d",a,b);
   printf("after swapping a=%d, b=%d",a,b);
void swap(int a,int b){
   int t;


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=10 b=20