#include <stdio.h>
int add(int a, int b)
{
int r;
r = a + b;
return r; // or just return a+b;
}
int div(int a, int b)
{
return a/b;
}
int main()
{
int cislo_a;
int cislo_b;
char operator;
printf("Zadej operator (+ nebo /): ");
scanf(" %c", &operator);
printf("Zadej hodnotu a: ");
scanf("%d", &cislo_a);
printf("Zadej hodnotu b: ");
scanf("%d", &cislo_b);
printf("Operator: %c, cislo_a: %d, cislo_b: %d\n", operator, cislo_a, cislo_b);
int result = 0;
if (c == '+') {
result = add(a, b);
}
else if (c == '/') {
if (b == 0) {
printf("Division by 0 is not defined, returning 1\n");
return 1;
}
else // not really needed because of return 1;
{
result = div(a, b);
}
}
printf("Result = %d\n", result);
return 0;
}