5/*Write a ‘C’ Program to swap the values of two variables by using call by reference*/


#include<stdio.h>
#include<conio.h>
int swap(int*n1,int*n2);
void main()
{
int num1,num2;
clrscr();
printf(“\n Enter two integer number \n”);
scanf(“%d%d”,&num1,&num2);
printf(“\n Before swapping \n”);
printf(“\n num1=%d num2=%d”,num1,num2);
swap(&num1,&num2);
printf(“\n After swapping \n”);
printf(“\n num1=%d num2=%d”,num1,num2);
getch();
}
int swap(int*n1,int*n2)
{
int temp;
temp=*n1;
*n1=*n2;
*n2=temp;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s