Ok, I know almost nothing about C++, so I was wondering if anyone could assist me in fixing my simple learning base program. I mean not to disturb more skilled programmers with my lack of knowledge, but to gain more knowledge of my own.
My current program is just a simple input output command window calculator.
Ok, so my code follows as shown:
Code:
#include "stdafx.h"
#include <iostream>
#include "conio.h"
//using namespace std;
float num1; // first integer
float num2; // second integer
int add; // addition [+]
int sub; // subtraction [-]
int mul; // multiplication[*]
int quo; // answer to division [/]
int sum; // answer to addition [+]
int difference; // answer to subtraction [-]
int product; // answer to multiplication[*]
// =
int method; // method e.g. ( +, -, *, / )
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "Enter first integer/float: " << std::endl;
std::cin >> num1;
std::cout << "Enter second integer/float value: " << std::endl;
std::cin >> num2;
std::cout << "Enter method ( +, -, *, / )" << std::endl;
std::cin >> method;
if(method == '+') {
sum = num1 + num2;
std::cout << sum << std::endl;
}
else if(method == '-') {
difference = num1 - num2;
std::cout << difference << std::endl;
}
else if(method == '*') {
product = num1 * num2;
std::cout << product << std::endl;
}
else if(method == '=') {
quo = num1 / num2;
std::cout << quo << std::endl;
}
else {
std::cout << "Unknown function, please use [ +, -, *, / ]" << std::cout;
}
}
If anyone can help, without just doing it for me, I'd appreciate it so much. Any help is greatly appreciated. Thanks in advance!
When I say almost no knowledge of C++, I didn't mean I copied this code, I know Java and am trying to learn C languages now, I am not a code leech so please don't assume I ripped this code off.