954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

need help with calculator program in C

i need help on how to make a calculator program on C.

for example:
100+3*(344-45)-3/20= ?

ive done a part of it, but it doesnt even give the right answer. the user inputs anything (excluding letters and some puncts). it accepts the equation as a string. ive already converted the string into integers using atoi() fn but im stucked and i dont know what to do next. i made a program similar to this but it doesnt follow the precedence of the operators and it cant compute the answer when you include parenthesis on it...

I need help badly! thanks....

*anything from telling me what to do next will do or any other will do* ill just try to analyze all your answers and see if i can really get it... :lol:

deathscythe129
Newbie Poster
1 post since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

Oddly enough, I answered this very question on another forum yesterday. The trick is to convert the expression to postfix so that you can easily evaluate it with a stack based approach. Alternatively, you could build an expression parse tree, but that just adds extra unnecessary steps in most cases.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Please read the Announcement .

Though I can't specifically say that you're doing a homework problem, the signs are there. We don't do work for you. Please post some code, and we'll help you troubleshoot.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

i need help on how to make a calculator program on C.

for example: 100+3*(344-45)-3/20= ?

ive done a part of it, but it doesnt even give the right answer. the user inputs anything (excluding letters and some puncts). it accepts the equation as a string. ive already converted the string into integers using atoi() fn but im stucked and i dont know what to do next. i made a program similar to this but it doesnt follow the precedence of the operators and it cant compute the answer when you include parenthesis on it...

I need help badly! thanks....

*anything from telling me what to do next will do or any other will do* ill just try to analyze all your answers and see if i can really get it... :lol:


did you already fix this????? i ned program like yours too.........
could you help me?????please??????????/

trenzkun
Newbie Poster
2 posts since Mar 2010
Reputation Points: 4
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You