Que - make a program for swapping of two numbers?
#include<iostream>
using namespace std;
void getdata ()
{
int a,b;
cout<<"enter first number :";
cin>>a;
cout<<"enter second number :";
cin>>b;
}
void swap()
{
int a,b;
a=a+b;
b=a-b;
a=a-b;
cout<<"after swapping first :"<<a<<endl;
cout<<"after swapping second "<<b;
}
int main()
{
getdata();
swap();
return 0;
}
Result:-
Tags
Function example