0

I'm trying to write a code where I have to input two numbers and an operator as a char in C language and print them:

int main() {
int a,b;
char opr;
printf("Enter a and b: ");
scanf("%d %d",&a,&b);
printf("Enter operator: ");
scanf("%c",&opr);
printf("\n%d %c %d",a,opr,b);
return 0;
> }

But for some reason every time I run the code the program ignores the second scanf() function printing the second printf() with the value of a and b is printed beneath it by one line.

I tried removing the spaces between the format specifiers but it didn't work. What is wrong here, more importantly why is it ignoring the second scanf()?

Keanu
  • 11
  • 2

0 Answers0