Calculator program does not perform the correct arithmetical operations

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  
    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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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.

http://www.cplusplus.com/forum/beginner/179361/
Topic archived. No new replies allowed.