C++ Program To Swap Two Numbers Using Functions

#include<iostream.h>
#include<conio.h>
void swap(int&,int&);
void main()
{
 clrscr();
 int a,b,c;
 cout<<"Enter one numbers: ";
 cin>>a;
 cout<<"Enter second number: ";
 cin>>b;
 swap(a,b);
 cout<<a<<" "<<b;
 getch();
}
void swap(int &a,int &b)
{
 int c;
 c=a;
 a=b;
 b=c;
}

OUTPUT:

Sharing Is Caring

Leave a Comment