Swap Value By Function
#include<iostream.h>
#include<conio.h>
void swap(int &a,int &b)
{
int c;
c=a;
a=b;
b=c;
}
void swap(char &a,char &b)
{
char c;
c=a;
a=b;
a=c;
}
void swap(float &a,float &b)
{
float c;
c=a;
a=b;
a=c;
}
void main()
{
int a,b;
float c,d;
char e,f;
cout<<"enter value of a & b";
cin>>a>>b;
swap(a,b);
cout<<a<<b;
getch();
}
#include<conio.h>
void swap(int &a,int &b)
{
int c;
c=a;
a=b;
b=c;
}
void swap(char &a,char &b)
{
char c;
c=a;
a=b;
a=c;
}
void swap(float &a,float &b)
{
float c;
c=a;
a=b;
a=c;
}
void main()
{
int a,b;
float c,d;
char e,f;
cout<<"enter value of a & b";
cin>>a>>b;
swap(a,b);
cout<<a<<b;
getch();
}
Post a Comment