This commit is contained in:
Weber 2024-10-14 11:54:21 +00:00
parent a3ca850437
commit 3f19705323

View File

@ -58,7 +58,8 @@ bool delit(KalkulackaZasobnik *kalkulacka) {
float a, b; float a, b;
if (vyber(kalkulacka, &a, &b)) { if (vyber(kalkulacka, &a, &b)) {
if (a == 0) { if (a == 0) {
return false; // Delenie nulou printf("division by zero\n");
return false;
} }
return vloz(kalkulacka, b / a); return vloz(kalkulacka, b / a);
} }
@ -119,12 +120,10 @@ int main() {
} }
break; break;
case '/': case '/':
if (delit(&kalkulacka)) { if (!delit(&kalkulacka)) {
zobraz_zasobnik(&kalkulacka);
} else {
printf("division by zero\n");
return 0; return 0;
} }
zobraz_zasobnik(&kalkulacka);
break; break;
default: default:
printf("no input\n"); printf("no input\n");