Why is this not working?

Pressing B is supposed to do subtractiona - (whatever next 4 digits you enter)
instead it just outputs what you originally did

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  #include <iostream>

using namespace std;


    int main()
    {
        char a;



        int value = 1;
        int x;
        int sum;

        sum = 0;

        cout << "a: Addition \nb: Subtraction" << endl;
        cin >> a;

        if(a == 'a'){
            cout << "enter 5 digits" << endl;
        while (value <= 5){
            cin >> x;
            sum = x + sum;
            value = value ++;
        }
            cout << "Your answer is " << sum;
        }
        int subtractiona;
        int subtractionb;
        int difference;


        if(a == 'b'){
            cout << "enter 5 digits" << endl;
            cin >> subtractiona;

        while (value <= 4){
            cin >> subtractionb;
            difference = subtractiona - subtractionb;
            difference = subtractiona;
            value++;
        }
            cout << "Your answer is " << difference;

        }





    return 0;
    }
difference = subtractiona - subtractionb;
difference = subtractiona;

I think this is redundant. :)
So what would I do instead?
just replace the second one.
So those lines will be changed into:
difference = subtractiona - subtractionb;
subtractiona = difference;

---EDITED---
Last edited on
Topic archived. No new replies allowed.