From f65f9c0c03d88c5f9864a42b5e2e5b7d2b727d6f Mon Sep 17 00:00:00 2001 From: st529yr Date: Wed, 20 Mar 2024 17:14:16 +0100 Subject: [PATCH] funguje --- a1/program.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/a1/program.c b/a1/program.c index 2d436c8..7c07d75 100644 --- a/a1/program.c +++ b/a1/program.c @@ -15,6 +15,11 @@ char* evaluate_expression(char* expression) { return "CHYBA"; } + // Kontrola delenia nulou + if (operator == '/' && num2 == 0) { + return "ZLE"; + } + // Vykonanie operácie a porovnanie s očakávaným výsledkom switch (operator) { case '+': @@ -27,10 +32,6 @@ char* evaluate_expression(char* expression) { result = num1 * num2; break; case '/': - // Kontrola delenia nulou - if (num2 == 0) { - return "CHYBA"; - } result = num1 / num2; break; default: