September 5th, 2012, 10:35 PM
Stuck on problem
Hello, I am teaching myself programming using Kochan's "Programming in C" book.
I am stuck on an exercise and was hoping you guys could help me out. Here is the question:
4. Write a program that acts as a simple “printing” calculator.
The program should allow the user to type in expressions of the form:
The following operators should be recognized by the program:
+ - * / S E
The S operator tells the program to set the “accumulator” to the typed-in number.
The E operator tells the program that execution is to end.
The arithmetic operations
are performed on the contents of the accumulator with the number that was keyed in acting as the second operand.
The following is a “sample run” showing how the program should operate:
10 S //Set Accumulator to 10
= 10.000000 //Contents of Accumulator
2 / //Divide by 2
= 5.000000 //Contents of Accumulator
55 - //Subtract 55
100.25 S //Set Accumulator to 100.25
4 * //Multiply by 4
0 E //End of program
End of Calculations.
Make certain that the program detects division by zero and also checks for unknown operators.
Thank you so much for your help guys!
September 6th, 2012, 01:42 AM
September 6th, 2012, 10:39 AM
What is the help you're looking for?
If you post some code, or also good the outline of an algorithm, or a plan, we can help fill in the details or suggest.
Cross-posting curtails interest.
[/code] are essential for python code and Makefiles!
September 6th, 2012, 03:06 PM
...you have the most confusing username
Originally Posted by b49P23TIvg
Comments on this post
"Life is not a journey with the intent on arriving at the finish line in a pretty and well preserved body. But rather to skid in broadside, totally worn out, thoroughly used up and loudly proclaiming, "Wow! What a ride!" -Anonymous
|| Diablo 2 LOD Modding
|| OLGA's BACK!