Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 21994

Modulo division within switch statement giving errors with GCC, written in C [closed]

$
0
0
#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.


Viewing all articles
Browse latest Browse all 21994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>