scanf
takes the address of the variable in which it stores the input value. You need to change your scanf
calls to
scanf("%d", &n1);
scanf("%d", &n2);
// ^ note the & operator
Also, note that it's undefined behaviour to call fflush
on an input stream. So, fflush(stdin)
is not correct. You need to manually read and discard extraneous input left over in the stdin
stream.