Program of Call by value for swapping two values
#include<stdio.h>
void swap(int a, int b)
{
int temp;
temp=a;
a=b;
b=temp;
}
void main()
{
int a=5;
int b=10;
/*printf("c-programcodes.blogspot.in");*/
swap(a,b); /*the values goes out of scope after the function is executed*/
printf("values are not swapped");
printf("a=%d\n",a);
printf("b=%d",b)
}
==OUTPUT==
values are not swapped
a=5
b=10
#include<stdio.h>
void swap(int a, int b)
{
int temp;
temp=a;
a=b;
b=temp;
}
void main()
{
int a=5;
int b=10;
/*printf("c-programcodes.blogspot.in");*/
swap(a,b); /*the values goes out of scope after the function is executed*/
printf("values are not swapped");
printf("a=%d\n",a);
printf("b=%d",b)
}
==OUTPUT==
values are not swapped
a=5
b=10