I'm having a problem with my program skipping over the 2nd scanf function. I am new to programming and am not sure why this is.
when I run this I do not get prompted for a 2nd input, it just skips right over it.
Code:int main(void) { int success,m,n,ans,input; char op; printf("Enter a simple arithmetic expression.\n"); success = scanf("%d%c%d\n",&m,&op,&n); switch(op) { case'+': ans = m + n; printf("What is the answer to %d%c%d?\n",m,op,n); scanf(" %d\n" , &input); if(ans == input) { printf("correct!\n"); } else { printf("No, the correct answer is %d\n",ans); } break; case'-': ans = m - n; break; case'*': ans = m * n; break; case'/': ans = m / n; break; case'%' ans = m % n; break; } printf("%d\n",success); return 0;



LinkBack URL
About LinkBacks


