#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
void swap(int &,int &);
cout<<“Enter two values:”;
cin>>a>>b;
cout<<“nBefor swapping:na=”<<a<<“tb=”<<b;
swap(a,b);
cout<<“nnAfter swapping:na=”<<a<<“tb=”<<b;
getch();
}
void swap(int & x,int & y)
{
int temp;
temp=x;
x=y;
y=temp;
}
it is not compiling
compiler is generating error that “cin” and “cout” are not declared (first use this function)
Add “using namespace std;” Its missing here
Great tutorial, love how it’s well explained. Altho error coming on output, so please do update the article. Thanks 🙂
Thank u for explaining greatly.Ihad enjoyed this tutorial a lot.
/* —- Here is the correct program —- */
#include
#include
using namespace std;
int main()
{
system(“cls”);
int a,b;
void swap(int &,int &);
cout<>a>>b;
cout<<"\nBefor swapping:\na="<<a<<"\tb="<<b;
swap(a,b);
cout<<"\n\nAfter swapping:\na="<<a<<"\tb="<<b;
getch();
return 0;
}
void swap(int & x,int & y)
{
int temp;
temp=x;
x=y;
y=temp;
}
#include
#include
void main()
{
// clrscr();
int a,b;
void swap(int &,int &);
cout<>a>>b;
cout<<"nBefor swapping:na="<<a<<"tb="<<b;
swap(a,b);
cout<<"nnAfter swapping:na="<<a<<"tb="<<b;
getch();
}
void swap(int & x,int & y)
{
int temp;
temp=x;
x=y;
y=temp