Program
#include <stdio.h>
void change(int a, int b)
{
int t=a;
a = b;
b = a;
printf("\nIn the Function Values are changed");
printf("\na= %d and b= %d", a, b);
}
int main()
{
printf("***************************************************************");
printf("\n***************************************************************");
printf("\n** WAP to explain Call by Value Method **");
printf("\n** Created by Sheetal Garg **");
printf("\n** Assistant Professor **");
printf("\n** Phone No:9467863365 **");
printf("\n***************************************************************");
printf("\n***************************************************************\n");
int a, b, temp;
printf("\nEnter two numbers : ");
scanf("%d%d", &a, &b);
printf("\n\nNumbers before Calling Function (in the main) are");
printf("\na= %d and b=%d\n", a, b);
change(a, b);
printf("\n\nAfter Calling Function, Values (in the main) are not Changed");
printf("\na is %d and b is %d", a, b);
return 0;
}
Output
*************************************************************** *************************************************************** ** WAP to explain Call by Value Method ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** *************************************************************** *************************************************************** Enter two numbers : 50 60 Numbers before Calling Function (in the main) are a= 50 and b=60 In the Function Values are changed a= 60 and b= 50 After Calling Function, Values (in the main) are not Changed a is 50 and b is 60