From 7207054466cdf9d2294e698eef795506a77acd72 Mon Sep 17 00:00:00 2001 From: Peter Petrek Date: Thu, 21 Oct 2021 22:37:40 +0200 Subject: [PATCH] /0 --- cv3/program.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cv3/program.c b/cv3/program.c index 0e2b911..31c15b9 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -34,6 +34,10 @@ int main() { printf("%.2f \n",databaza[counter-2].price); } if(input[0] == '/'){ + if(databaza[counter-1].price == '0'){ + printf("division by zero"); + return 0; + } printf("%.2f \n",databaza[counter-2].price); printf("%.2f %.2f \n",databaza[counter-2].price, databaza[counter-1].price); databaza[counter-2].price = databaza[counter-2].price / databaza[counter-1].price;