I just started learning C, but I've already encountered a problem. I want to write a simple calculator, but -I don't know why- the second integer always counts as 0. I just can't find out what could be the problem.
Here's my code:
int main(){
int a, b;
char c;
printf("Enter 2 numbers:\n");
scanf("%d %d", &a, &b);
printf("Enter an operator:\n");
scanf("%s", &c);
switch(c){
case '+':
printf("%d\n", a+b);
break;
case '-':
printf("%d\n", a-b);
break;
case '*':
printf("%d\n", a*b);
break;
case '/':
printf("%d\n", a/b);
break;
}
}
Thanks for the help:)