#include<iostream.h>
#include<conio.h>
int add,sub,mul;
float div;
class math
{
int a,b;
public:void accept()
{
cout<<"\nenter two number:-";
cin>>a>>b;
}
void operator +()
{
add=a+b;
}
void operator -()
{
sub=a-b;
}
void operator *()
{
mul=a*b;
}
void operator /()
{
div=a/b;
}
void display()
{
cout<<"\naddition="<<add
<<"\nsubtraction="<<sub
<<"\nmultiplication="<<mul
<<"\ndivision="<<div;
}
};
int main()
{
math m1;
m1.accept();
+m1;
-m1;
*m1;
/m1;
m1.display();
getch();
return 0;
}
#include<conio.h>
int add,sub,mul;
float div;
class math
{
int a,b;
public:void accept()
{
cout<<"\nenter two number:-";
cin>>a>>b;
}
void operator +()
{
add=a+b;
}
void operator -()
{
sub=a-b;
}
void operator *()
{
mul=a*b;
}
void operator /()
{
div=a/b;
}
void display()
{
cout<<"\naddition="<<add
<<"\nsubtraction="<<sub
<<"\nmultiplication="<<mul
<<"\ndivision="<<div;
}
};
int main()
{
math m1;
m1.accept();
+m1;
-m1;
*m1;
/m1;
m1.display();
getch();
return 0;
}
No comments:
Post a Comment