Write a program in C to show call by reference.
#include<stdio.h> #include<conio.h> int swap(int *x,int *y); void main() { int a,b; printf("Enter two nos:-"); scanf("%d%d",&a,&b); printf("Value of a=%d & Value of b=%d before swap.",a,b); swap(&a,&b); printf("\nValue of a=%d & Value of b=%d after swap.",a,b); getch() } int swap(int *x,int *y) { int temp; temp=*x; *x=*y; *y=temp; }Output:-
0 Comments