Initialization

This commit is contained in:
Kozar 2024-03-27 14:37:04 +01:00
parent ddb74790ad
commit 3cc550a97b

View File

@ -8,9 +8,8 @@ int main() {
double num1, num2, result, expected_result;
char op;
while (fgets(line, sizeof(line), stdin) != NULL) {
num1 = num2 = result = 0;
op = '\0';
// Read the input line
fgets(line, sizeof(line), stdin);
// Remove any spaces between symbols
for (int i = 0; line[i] != '\0'; i++) {
@ -28,13 +27,13 @@ int main() {
// Check if the input is valid
if (op != '+' && op != '-' && op != '*' && op != '/') {
printf("CHYBA\n");
continue;
return 1;
}
// Check for division by zero
if (op == '/' && num2 == 0) {
printf("CHYBA\n");
continue;
return 1;
}
// Perform the calculation
@ -59,7 +58,6 @@ int main() {
} else {
printf("ZLE\n");
}
}
return 0;
}