need help with calculator program in C

Reply

Join Date: Jan 2005
Posts: 1
Reputation: deathscythe129 is an unknown quantity at this point 
Solved Threads: 0
deathscythe129 deathscythe129 is offline Offline
Newbie Poster

need help with calculator program in C

 
0
  #1
Jan 9th, 2005
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:
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,622
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 713
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: need help with calculator program in C

 
0
  #2
Jan 9th, 2005
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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: need help with calculator program in C

 
0
  #3
Jan 10th, 2005
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.
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC