Member Avatar

Hi there folks, I got some minor problem with this code: [CODE] #include <stdio.h> #include <stdlib.h> int main(){ char option, factor; printf("Choose your operator: \"+\" ; \"-\" ; \"*\" ; \"/\" \n>\t"); scanf(" %c", &option); printf("You chose : %c \nChoose your factor:\n>\t", option); scanf("%d", &factor); printf("You chose : %i\n",factor); printf(" %c", option); if(option=='+'){ printf("It's WORKING!"); system("pause"); } return 0; } [/CODE] and it doesn't work. Program skips "if()" as if it wasn't there and continues with "return 0;". On the other hand if I remove "scanf("%d", &factor);" it works prefectly fine! Can anyone tell me why? regards

Member Avatar
0
13

The End.