How to write a C++ Program to swap two numbers using function in C++ Programming ?
C++ Program to swap two numbers using function. |
Solution:
//Program to swap two numbers using function.
#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;
}
This C++ Program to swap two numbers using function.