[ back to toc ]

simulate a calculator

Date: 2002/05/24 10:29

Q:
In the name of God
I am a student, studying computer .Writing a program to simulate the
functions of a calculator on the computer , is on
of my destiny with C language .
I have tried very hard ,but feel the requirement of being assisted by an
expert in the field.
could you advise me in the following issues:
1-What subjects should I consider in the simulator calculator?
2-How should these items be written?
3-How should I choose my inputs to the calculator ,which it can be
differentiate
between the input figures and the relative operators like plus and minus.
*NAME-DELETED* Shafia

A:
*NAME-DELETED*,

I would say that this is actually programming. Your calculator can read
the characters from the standard input, which is the keyboard in most
cases. The output can be sent to the screen. You can program it in the
language C as you want to learn that language. But this is not simple.

There are functions to read from the keyboard, named getchar(), scanf()
and alikes. You should read the documentation on those.

You can print out the result that you calculate using the function
printf(). Also consult the documentation how that works.

You can implement the four most simple operators: + - / and *

You should read a number using scanf first, then read the operator and
read another num,ber. Finally you should perform the calculation in your
program and print out the result.

regards,
Peter

[ back to toc ]