#include <stdio.h>#include <math.h>int main(){ float num1, num2; char op; scanf("%f", &num1); scanf("%c", &op); scanf("%f", &num2); switch(op) { case '%': int n1 = num1; int n2 = num2; int re = n1%n2 printf("\n%s %d\n","Result = ",re); break; } }
The above code when I try to compile with GCC (MacOS) on gives me :
error: expected expression
int n1 = num1;
error: use of undeclared identifier 'n2'
int re = n1%n2
Note: The above is a minimum reproducible example. The original is very lengthy code, but the error appears to lie somewhere in the lines above.