fix: modulo by zero

This commit is contained in:
SinusFox
2023-05-10 09:42:58 +02:00
parent 3409df4e15
commit ea2aef7ed1
+2 -2
View File
@@ -20,10 +20,10 @@ int main() {
multiplication = first * second; multiplication = first * second;
if (second != 0) { if (second != 0) {
division = first / second; division = first / second;
modulo = first % second;
} else { } else {
printf("\n\nError: Dividing by 0 is not allowed. Output will be 0.\n\n"); printf("\nError: Dividing by 0 is not allowed. Output will be 0 for devision and modulo.\n\n");
} }
modulo = first % second;
// output of calculation // output of calculation
printf("The results are:\n+ = %i\n- = %i\n* = %i\n/ = %f\nmod = %i", addition, subtraction, multiplication, division, modulo); printf("The results are:\n+ = %i\n- = %i\n* = %i\n/ = %f\nmod = %i", addition, subtraction, multiplication, division, modulo);