--Originally published at Loading…
This is what Ken asked us to do:
Ask the user for two integer values, then use those two values to calculate and show the following:
- The sum of the two numbers.
- The difference of the two numbers.
- The product of the two numbers.
- The integer based division of the two numbers (so no decimal point). First divided by second.
- The remainder of integer division of the two numbers.
So the first thing that I did was to declare all my variables as an integer with “int”. n01 and n02 are for the numbers to print on the terminal. Then the other 5 variables are for each one of the results of the operations that the program had to realize. Later I put the instruction of cout to show the message “Enter the number” (and all the others messages) and cin in order that the user could give the value to the variable with the number that he wishes. Finally to give a value to n03 (or the others 4 variables) I wrote the formula for each operation, and print the result on the screen.
This is my code:
It was nice to remember the basic things!!