# how to write a program of a simple calculator?

This is a discussion on how to write a program of a simple calculator? within the C Programming forums, part of the General Programming Boards category; i'm new to the C programming. So, i need u guys help. i want to write a program of a ...

1. ## how to write a program of a simple calculator?

i'm new to the C programming. So, i need u guys help. i want to write a program of a calculator which can solve addition,subtraction, division and multiply. however, 0 cannot divide by any number. How to write this? write a program with explanation, please.I want to learn it.

3. Originally Posted by yeohwl91
i'm new to the C programming. So, i need u guys help. i want to write a program of a calculator which can solve addition,subtraction, division and multiply. however, 0 cannot divide by any number. How to write this? write a program with explanation, please.I want to learn it.
Nope, we're not going to write it for you. So follow the links in post #3 and start learning...

Yer basic 4 banger calculator is very easily written and is a great learning exercise for students.

Forget about source code for the moment...

The best way to get started is to sit down with a few sheets of paper and a pencil and analyse the problem... what does it have to do? What choices does the user have? What functions does it perform? How does it inform the user of the results? And so on...

Once you fully understand what is required, you can start planning your code. Work in small steps until you have a description of exactly what the program has to do in very small steps.

The third step is to write your code from the plan you created.

Finally test your code and make sure it works as expected.

Notice that you don't actually start thinking about C or Source Code until the third step of this process. This is because nobody has ever solved a problem they don't understand.

4. Code:
```#include<stdlib.h>
int main( void )
{
system( "calc.exe" );
return 0;
}```

Quzah.

5. Originally Posted by quzah
Code:
```#include<stdlib.h>
int main( void )
{
system( "calc.exe" );
return 0;
}```
ROFL ... now that's just nasty... effective... but nasty.