anonymous
  • anonymous
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
Computer Science
katieb
  • katieb
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
scanf("%d\n", &"%d\n", $one); is this a typo?
anonymous
  • anonymous
also scanf("%ch\n", &sym); %c is the correct conversion specifier and not %ch :-(
anonymous
  • anonymous
instead of that line, you can use sym = getchar()

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
Finally, you've got printf("The result is: ", ans) with no %d conversion specifier in the format string.
anonymous
  • anonymous
C is a lot complicated than C++. :P
anonymous
  • anonymous
not really. It's just that scanf() is so inconvenient
anonymous
  • anonymous
now it shows 4+4=1
anonymous
  • anonymous
http://ideone.com/bTFbT
anonymous
  • anonymous
hahaha I have a bug in there: one / 2 instead of one / two :-P
anonymous
  • anonymous
http://ideone.com/xCtvs

Looking for something else?

Not the answer you are looking for? Search for more explanations.