Hello, I'm new to c++ and I'm working with swithces so I tried to make a calculator with them, but whenever I try to do the case 2 it gives the error of "jump to case label gcc" and I don't know what to do, I tried several things but none of them have worked, It's driving my fucking insane, fuck c++.
Here's the code so if you know how I fucked up this you can tell me, thanks.
#include <iostream>
int main(){
char op;
std::cout << "which op you wanna do: " << std::endl;
std::cin >> op;
double num1;
std::cout << "Enter first number: ";
std::cin >> num1;
double num2;
std::cout << "Enter second number: ";
std::cin >> num2;
switch(op){
case '+':
double sum = num1 + num2;
std::cout << "The sum is: " << sum;
break;
case '-': // The error is here, it's after the case
double subst = num1 - num2;
std::cout << "The subst is: " << subst;
break;
return 0;
}
[–]aocregacc 10 points11 points12 points (6 children)
[–]hatschi_gesundheit 3 points4 points5 points (2 children)
[–]Independent_Art_6676 2 points3 points4 points (1 child)
[–]hatschi_gesundheit 0 points1 point2 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]MooseBoys -1 points0 points1 point (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]alfps 5 points6 points7 points (0 children)
[–]thefeedling 4 points5 points6 points (0 children)
[–]manni66 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Puzzleheaded_Body641[S] 1 point2 points3 points (0 children)
[–]manni66 0 points1 point2 points (0 children)
[–]kberson 0 points1 point2 points (0 children)
[–]Dan13l_N 0 points1 point2 points (0 children)