So I am close to finishing my program but one last thing that's bothering me is that it outputs the wrong answer if it involves negative numbers or decimals. I am using a textbook example of performing the operations. These are the sections of code used to calculate
if (i==1) {
int n;
n = addition (a,b);
cout << "The answer is " << n;
}
//// This performs the addition operation
if (i==2) {
int n;
n = subtraction (a,b);
cout << "The answer is " << n;
}
//// This performs the subtraction operation
if (i==3) {
int n;
n = mulitplication (a,b);
cout << "The answer is " << n;
}
//// This performs the multiplcation operation
if (i==4) {
int n;
n = division (a,b);
cout << "The answer is " << n;
}
//// This performs the division operation
Don't worry about the variable i, it's just being used for which operation you want to do, here is the functions for the operations.
int subtraction (int a, int b)
{
int m;
m=a-b;
return m;
}
int addition (int a, int b)
{
int m;
m=a+b;
return m;
}
int mulitplication (int a, int b)
{
int m;
m=a*b;
return m;
}
int division (int a, int b)
{
int m;
m=a/b;
return m;
}
This works pretty well, unless it involves a remainder or negative numbers. I'd like to know how to incorporate it. If you would like to see the whole code I have it on an earlier post.