Calculators are made to calculate simple to difficult equations or even just the basic math equations. Addition, Subtraction, Multiplication and Division are the four basic mathematical operation and the foundation in creating equations that are used for calculating specific or certain things. Since kindergarten, we are taught how those operations work with numbers. So, I thought of making a program that can be helpful not just in our daily encounter with mathematics but also in teaching our younger ones about the four basic mathematical operation.
This program is used with a float data type identifier. The difference of float (%f) from int (%d) is that int only accepts whole numbers for input even on outputs. While float accepts numbers with decimal points, also with the outputs. It is also a C++ language code. Check out the codes below.
#include <iostream> #include <conio.h> using namespace std; int main() { float num1 = 0.0f; float num2 = 0.0f; cout << "Enter a real number n1: "; cin >> num1; cout << "Enter a real number n2: "; cin >> num2; cout << num1 << " + " << num2 << " = " << num1+num2 << endl; cout << num1 << " - " << num2 << " = " << num1-num2 << endl; cout << num1 << " * " << num2 << " = " << num1*num2 << endl; cout << num1 << " / " << num2 << " = " << num1/num2 << endl; getch(); }
The flow of the program is this. There are two storage memory declared at the top using the float data type identifier namely num1 and num2. That is where the inputs will be stored. After that, addition, subtraction, multiplication and division operations will be executed under the cout command. Cout is like printf it is the action command which will show you the output. But in C++ you can put additional arguments in cout command. Just like in the code shown above. Then, results will be shown. After that, you can terminate the program. Check out the sample output below.
Hope you enjoyed this program. We hope to hear from you. Thanks!
Slot games, how to play slot machine games online for fun
ReplyDeletePlay Slot games online for 광주 출장샵 fun or 진주 출장안마 find the best 구리 출장마사지 casino bonus for your game, plus all the best casino bonuses for new players. You may play for 대구광역 출장마사지 free now 하남 출장마사지