Program
#include <stdio.h>
void change(int *a, int *b)
{
int t=*a;
*a = *b;
*b = t;
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 Reference 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 Changed");
printf("\na is %d and b is %d", a, b);
return 0;
}
Output
*************************************************************** *************************************************************** ** WAP to explain Call by Reference 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 Changed a is 60 and b is 50