#include<iostream>
#include<conio.h>
using namespace std;
void swap(int &,int &); //function declaration
int main() //main function
{
int a,b;
cout<<"\nenter the two numberw:\n"<<endl;
cin>>a>>b;
cout<<"\n\nbefore swaping :";
cout<<"\nA="<<a;
cout<<"\nB="<<b;
swap(a,b); //functiom call
cout<<"\n\nAfter the swapping:";
cout<<"\nA="<<a;
cout<<"\nB="<<b;
getch();
return 0;
}
void swap(int &x,int &y)
{
int temp;
temp=x;
x=y; //function body...
y=temp;
}
No comments:
Post a Comment