hello.
i am a complete beginner in C, so please bear with me .
well i wrote a simple program , but i have no idea why it is not working! its pretty simple you know !
here is my code
Code:
//in the name of god
#include<stdio.h>
int main()
{
int x,y;
char c;
printf("\nPlease Enter 2 operands and then your desigred operator(+/*)");
scanf("%d%d%c",&x,&y,&c);
printf("x = %d,,y = %d Operator:%c\n",x,y,c);
if (c == '*' )
{
printf("x * y = :%d",x*y);
}
else if (c == '+' )
{
printf("x + y:%d",x+y);
}
else
printf("error happened!");
return 0;
}
what is wrong with
Code:
scanf("%d%d%c",&x,&y,&c);
i noticed that if i write
Code:
scanf("%d%c%d",&x,&c,&y);
it would work perfectly! but i really dont know what is the difference between the two!
would anyone help me ?
thanks