#include<iostream.h>
#include<conio.h>
class twonum
{
private :
int x,y;
public:
void getvalues()
{
cout<<"enter any two numbers";
cin>>x>>y;
}
void putvalues()
{
cout<<"\n\n"<<x<<","<<y;
}
int add(int x,int y)
{
return(x+y);
}
int multiply(int x,int y)
{
return(x*y);
}
void swap(int x,int y)
{
int c;
c=x;
x=y;
y=c;
cout<<x<<","<<y;
};
void main()
{
clrscr();
int k,j,l;
twonum s;
s.getvalues();
s.putvalues();
k=s.add(x,y);
cout<<"addition:"<<k;
j=s.multiply(x,y);
cout<<"multiplication:"<<j;
s.swap(x,y);
getch();
}
Recommended Answers
Jump to PostRegarding conio.h, getch, clrscr, not everyone has conio.h. You might try changing iostream.h to iostream. "void main" should probably be "int main" and your main function should return 0.
Those "problems" might allow it to compile on your machine and not on others, but the actual errors are below.
…
All 4 Replies
rproffitt
1,895
"Nothing to see here."
Moderator
AssertNull
1,094
Practically a Posting Shark
AssertNull
1,094
Practically a Posting Shark
rproffitt
commented:
You made good points as well. The code, well, it's just a code dump and run with many dangling unspoken questions.
+11
tinstaafl
1,131
Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.