With calculators in place, mathematics has been simplified where very large numbers can be easily manipulated in a very minimum time, but have you ever wondered how these calculators are designed to do what they do;

So let’s go ahead and see how;

You can use any IDE (integrated development environment) you have installed in your pc to try it out, while I will be using CodeBlocks.

  1. So the first thing is to open up your IDE, and when you opens the source file, CodeBlocks gives the following input for you by default, but if your using an IDE that doesn’t give you the following information then you can manually type in the following; from “#include <stdio.h> up to the “return 0; }”

2. Now lets begin with a simple calculator that adds up two values, and the values have to be put in by the user, The first thing we are going to need are variables to hold the various user inputs.

3. Then after that we print out a message asking a user to input a particular value, and also a function that will accept the input and store it (that is the scanf ).

In the scanf function, “%d” allows the user to input whole numbers, while the “&value1” stores the input in the the variable value1

4. After that, we print out an answer that sums up the two values as follow;

5. And when we compile and run the program, this window pops out asking for the user input.

6. And when the you input the first value like 20 and press the enter key, you’ll be asked to input the second value

7. Then when you input the second value like 30 and press enter you should be able to get 50 as your answer

And as simple as that, we have designed a simple calculator that can get user’s input and sum it up