diff --git a/cv3/program.c b/cv3/program.c index db26164..d68d985 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -75,7 +75,7 @@ int main() { } float b = pop_stack(&mystack); float a = pop_stack(&mystack); - float result; + float result = 0; switch (input[0]) { case '+': @@ -90,21 +90,25 @@ int main() { case '/': if (b == 0) { printf("Error: Division by zero.\n"); - break; + + push_stack(&mystack, a); + push_stack(&mystack, b); + print_stack(&mystack); + continue; } result = a / b; break; default: printf("Error: Unknown operation '%s'.\n", input); - push_stack(&mystack, a); + + push_stack(&mystack, a); push_stack(&mystack, b); - break; + print_stack(&mystack); + continue; } - if (result) { - push_stack(&mystack, result); - print_stack(&mystack); - } + push_stack(&mystack, result); + print_stack(&mystack); } }