Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

Write a program to swap two nos. using call by value and call by reference.

Write a program to swap two nos. using call by value and call by reference.

#include<stdio.h>
#include<conio.h>
int swapr(int *,int *);
int swapv(int x,int y);
int main()
{
int a=10,b=20;
clrscr();
swapr(&a,&b);
printf("\na=%d b=%d",a,b);
swapv(a,b);
printf("\na=%d b=%d",a,b);
}
int swapr(int *x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
int swapv(int x,int y)
{
int t;
t=x;
x=y;
y=t;
printf("\nx=%d y=%d",x,y);
}


Output


Previous
Next Post »