Can some one debug it pls..
#include
int main()
{
int one,two,ans=0;
char sym;
printf("Enter a number: ");
scanf("%d/n",&"%d/n",&one);
printf("Enter another number :");
scanf("%d/n",&two);
printf("Enter an operator(+,-,*,/): ");
scanf("%ch/n",&sym);
if(sym=='+')
ans=one+two;
else if(sym=='-')
ans=one-two;
else if(sym=='*')
ans=one*two;
else
ans=one/two;
printf("The result is: ",ans);
getch();
return 0;
}
It always show same result i.e -7188
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (anonymous):
scanf("%d\n", &"%d\n", $one); is this a typo?
OpenStudy (anonymous):
also scanf("%ch\n", &sym); %c is the correct conversion specifier and not %ch :-(
OpenStudy (anonymous):
instead of that line, you can use sym = getchar()
OpenStudy (anonymous):
Finally, you've got printf("The result is: ", ans) with no %d conversion specifier in the format string.
OpenStudy (anonymous):
C is a lot complicated than C++. :P
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (anonymous):
not really. It's just that scanf() is so inconvenient