C++ code help. (I'm a beginner...)

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
In c++, I’m Trying to make a very simple calculator with the “if” function, but I’m new to coding if you couldn’t tell.

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
“Thread 1: EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)” is the error code that I’m getting on the line with int sum4 = value1 / value2;

Any help from someone would be dope. Thanks homies.

```

#include
using namespace std;

int value1, value2;
int sum1 = value1 + value2;
int sum2 = value1 - value2;
int sum3 = value1 * value2;
int sum4 = value1 / value2;
int sign;

int main ()
{
cout << “Calculator” << endl;
cout << "Please enter your first number: " << endl;
cin >> value1;
cout << “Enter ‘1’ (Addition) ‘2’ (Subtraction) ‘3’ (Multiplication) ‘4’ (Division)” << endl;
cin >> sign;
if (sign > 4) cout << "Bruh. Try Again. " << endl;
else cout << “Please enter your second number” << endl;
cin >> value2;
if (sign == 1) cout << value1 << " + " << value2 << " = " << sum1 << endl;
if (sign == 2) cout << value1 << " - " << value2 << " = " << sum2 << endl;
if (sign == 3) cout << value1 << " * " << value2 << " = " << sum3 << endl;
if (sign == 4) cout << value1 << " / " << value2 << " = " << sum4 << endl;
return 0;
}

<do not remove the three backticks above>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.