Use a compiler with more warnings enabled.
Code:
$ gcc -Wall foo.c
foo.c:3:1: warning: parameter names (without types) in function declaration
float calculator(op, in1, in2);
^
foo.c: In function ‘calculator’:
foo.c:33:7: warning: type of ‘op’ defaults to ‘int’ [-Wimplicit-int]
float calculator(op, in1, in2)
^
foo.c:33:7: warning: type of ‘in1’ defaults to ‘int’ [-Wimplicit-int]
foo.c:33:7: warning: type of ‘in2’ defaults to ‘int’ [-Wimplicit-int]
foo.c:37:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=]
case '+' : printf("%.2f + %.2f = %.2f", in1, in2, in1+in2);
^
foo.c:37:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 3 has type ‘int’ [-Wformat=]
foo.c:37:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 4 has type ‘int’ [-Wformat=]
foo.c:39:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=]
case '-' : printf("%.2f - %.2f = %.2f", in1, in2, in1-in2);
^
foo.c:39:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 3 has type ‘int’ [-Wformat=]
foo.c:39:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 4 has type ‘int’ [-Wformat=]
foo.c:41:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=]
case '*' : printf("%.2f * %.2f = %.2f", in1, in2, in1*in2);
^
foo.c:41:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 3 has type ‘int’ [-Wformat=]
foo.c:41:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 4 has type ‘int’ [-Wformat=]
foo.c:43:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=]
case '/' : printf("%.2f / %.2f = %.2f", in1, in2, in1/in2);
^
foo.c:43:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 3 has type ‘int’ [-Wformat=]
foo.c:43:27: warning: format ‘%f’ expects argument of type ‘double’, but argument 4 has type ‘int’ [-Wformat=]
foo.c:46:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
The two main issues being
- your function definition and declaration lack any types.
- a lot of printf/scanf calls have inconsistent type/formats.