need help this program wont work

#include <iostream>
#include <string>
using namespace std;

int main()
{
int first;
int second;
int sum;
int summ;
std::string input;
cout << "Choose arithmetic: Addition or Subtraction? " << endl;
cin >> input;
if(input == "Addition")
{
int first;
int second;
int sum = first+second;
cout << "Enter the first number: " << endl;
cout << "Enter the second number: " << endl;
cout << "The sum of these numbers is: " << sum << endl;
}
{
if(input == "Subtraction")
int first;
int second;
int summ = first-second;
cout << "Enter the first number: " << endl;
cout << "Enter the second number: " << endl;
cout << "The sub of these numbers is: " << sum << endl;
}





return 0;
}
Last edited on
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
#include <iostream>
#include <string>
using namespace std;

int main()
{
    std::string input;
    cout << "Choose arithmetic: Addition or Subtraction? " ;
    cin >> input;

    if(input == "Addition")
    {
        int first;
        cout << "Enter the first number: "  ;
        cin >> first ;

        int second;
        cout << "Enter the second number: " ;
        cin >> second ;

        int sum = first + second; // compute the sum *after* reading in the values
        cout << "The sum of these numbers is: " << sum << '\n' ;
    }

    if(input == "Subtraction")
    {
        int first;
        cout << "Enter the first number: " ;
        cin >> first ;

        int second;
        cout << "Enter the second number: " ;
        cin >> second ;

        int diff = first - second;
        cout << "The difference of these numbers is: " << diff << '\n' ;
    }
}
thank you JLBorges
Topic archived. No new replies allowed.