i am writing a program for class and a switch i have in it won't break, but only one case won't break when i enter the sentinel value it goes back to the menu but the other case exits when the sentinel is entered and the default case works properly
the last break at the end outside of the braces is because the switch is inside a case of another switchCode:switch(choice){
case 1:
printf("Enter the length of the base(9999 to quit):\n");
scanf("%lf", &base);
while (base != 9999){
printf("Enter the length of the height:\n");
scanf("%lf", &height);
while(height < 0 || base < 0 ){
printf("Invalid input!\n");
printf("Enter the length of the base:\n");
scanf("%lf", &base);
printf("Enter the length of the height:\n");
scanf("%lf", &height);
area = .5 * base * height;
printf("The area of the triangle is %.2lf\n", area);
printf("Enter the length of the base(9999 to quit):\n");
scanf("%lf", &base);
}
}
break;
case 2:
printf("Enter the length of side 1(9999 to quit):\n");
scanf("%lf", &side1);
while (side1 != 9999){
printf("Enter the length of side 2:\n");
scanf("%lf", &side2);
printf("Enter the length of side 3:\n");
scanf("%lf", &side3);
while(side1 < 0 || side2 < 0 || side3 < 0){
printf("Invalid input!\n");
printf("Enter the length of side 1:\n");
scanf("%lf", &side1);
printf("Enter the length of side 2:\n");
scanf("%lf", &side2);
printf("Enter the length of side 3:\n");
scanf("%lf", &side3);
}
perimeter = side1 + side2 + side3;
printf("The perimeter of the triangle is %.2lf\n", perimeter);
printf("Enter the length of side 1(9999 to quit):\n");
scanf("%lf", &side1);
}
break;
default: printf("Invalid input!");
break;}
break;
plz help me if you can im new at this

