Hello, I just started teaching myself to code and I am having a problem with a calculator I am trying to make. The first part is a slope calculator that then converts to y=mx+b. The second is a normal calculator. When I run the normal calculator, it allows you to input the command, but then it doesnt do anything I tell it to after that.
switch(z){
case'+':
result = x+y;
break;
case'-':
result = x-y;
break;
case'*':
result = x*y;
break;
case'/':
if(y == 0){
cout << "DIV. BY 0 ERROR";
}else{
result = x/y;
}
break;
cout << "Result= " << result << "\n"; //should not be in the switch
}
A big improvement in your code would be naming the variables something more distinct than simple characters. It makes it easier for others to help as well :)
EDIT: Oh, and you can name multiple variables on one line: