C++ program to swap two numbers using function that is called by reference.
![](https://legalindiatech.com/wp-content/uploads/2023/04/C-legal-india-tech.png)
/* Write a program to swap two numbers using function that is called by
reference*/
#include<iostream.h>
#include<conio.h>
void swap(int *,int*);
void main()
{
clrscr();
int a,b;
cout<<“Enter value for a=”<<endl;
cin>>a;
cout<<“Enter value for b=”<<endl;
cin>>b;
swap(&a,&b);
cout<<“After swapping:”<<endl<<“a=”<<a<<” “<<“b=”<<b<<endl;
getch();
}
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}