Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

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
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.

Join Brainly to access

this expert answer

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

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

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

Not the answer you are looking for?

Search for more explanations.

Ask your own question