#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
//fen: first entered number. sen:second entered number. ma:mathematical action
double fen, sen;
double a, b, c, d;
char ma;
//a - sum outcome. b - difference outcome c - multipication outcome d - division outcome
a = fen + sen;
b = fen - sen;
c = fen*sen;
d = fen / sen;
cout << "Welcome to the world finest calculator\n";
cout << "Please enter the mathematical calculation you want to perform, using + for sum, - for difference, * for multipication and / for division\n";
cin >> fen >> ma >> sen;
if (ma = '+')
cout << "The sum of the numbers is:" << a << endl;
if (ma = '-')
cout << "The difference of the two numbers is:" << b << endl;
if (ma = '*')
cout << "The multipication of the two numbers is:" << c << endl;
if (ma = '/' )
cout << "The division of the two numbers is:" << d << endl;
cout << "Thank you for using the world best calculator" << endl;
return 0;
}
a = fen + sen;
b = fen - sen;
c = fen*sen;
d = fen / sen;
cout << "Welcome to the world finest calculator\n";
cout << "Please enter the mathematical calculation you want to perform, using + for sum, - for difference, * for multipication and / for division\n";
cin >> fen >> ma >> sen;
if (ma = '+')
cout << "The sum of the numbers is:" << a << endl;
if (ma = '-')
cout << "The difference of the two numbers is:" << b << endl;
if (ma = '*')
cout << "The multipication of the two numbers is:" << c << endl;
if (ma = '/' )
cout << "The division of the two numbers is:" << d << endl;
You work out the outputs (a, b, c, d) ... before you enter the inputs (fen, sen)! Your code shows great anticipation!
Try stepping through your code in order, line by line and you will see this.