1. ## I give up! can someone help me out please?

I am quite new to c++ and I am triying to make a console calculator, but I cant make it work! here is the code:

Code:
```#include <iostream>
using namespace std;
//Prototypes
float GetKey(char input2);
float multiplication(float num1, float num2);
float sum(float num1, float num2);
float divition(float num1, float num2);
float substraction(float num1, float num2);
void CalcFont();

int main()
{
int num1, num2;

float input1;
char input2;
float input3;

do
{
CalcFont();
cin >> input1 >> input2 >> input3;
} while (input2 != 'c' || input2 != 'C');

return 0;
}

GetKey(&input2)
{
if (*input2 == '*')
{
multiplication(num1, num2);
return multiplication(num1, num2);
}

if (*input2 == '+')
{
sum(num1, num2);
return sum(num1, num2)
}

if (*input2 == '/')
{
divition(num1, num2);
return divition(num1, num2);
}

if (*input2 == '-')
{
substraction(num1, num2);
return substraction(num1, num2);
}
}

multiplication(num1, num2)
{
return num1 * num2;
}

sum(num1, num2)
{
return num1 + num2;
}

divition(num1, num2)
{
return num1 / num2;
}

substraction(num1, num2)
{
return num1 - num2;
}

CalcFont()
{
cout << "---------\n";
cout << "|" << GetKey() << "       |\n";
cout << "|-------|---\n";
cout << "| 1 | 2 | * |\n";
cout << "|---|---|---\n";
cout << "| 3 | 4 | + |\n";
cout << "|---|---|---\n";
cout << "| 5 | 6 | / |\n";
cout << "|---|---|---\n";
cout << "| 7 | 8 | - |\n";
cout << "|---|---|---\n";
cout << "| 9 | C |\n";
cout << "---------\n";
}```
I alwas get many error keys and I cant figure out how to fix them, any help?

2. Tell us what the errors are, that'll make our jobs to help a lot easier!

3. >>GetKey(&input2)
Your function must match its prototype.
>>float GetKey(char input2)
Similarly for the other functions.

>>multiplication(num1, num2);
num1 and num2 are in main, they don't exist in the GetKey function.

>>if (*input2 == '*')
>>if (input2 == '*')

>>return sum(num1, num2)
Missing a semi-colon

>>GetKey() return value
The GetKey() function doesn't have a guaranteed return value. What happens if the user doesn't enter a valid symbol?

>>cout << "|" << GetKey() << " |\n";
Are you failed to pass any parameters to the GetKey() function.

>>multiplication(num1, num2);
>>return multiplication(num1, num2);
Why are you calling the multiplication function twice?

There's some logic problems too, but if you sort out the above, it might at least compile

4. thats...a lot...of errors

5. Thnks so much

6. I made some changes and this is how I got the code now:

Code:
```#include <iostream>
using namespace std;
//Prototypes
float GetKey(char input2);
float multiplication(float num1, float num2);
float sum(float num1, float num2);
float divition(float num1, float num2);
float substraction(float num1, float num2);
void CalcFont();

int main()
{
int num1, num2;

float input1;
char input2;
float input3;

do
{
CalcFont();
cin >> input1 >> input2 >> input3;
} while (input2 != 'c' || input2 != 'C');

return 0;
}

GetKey(char input2)
{
if (input2 == '*')
{
return multiplication(num1, num2);
}

if (input2 == '+')
{
return sum(num1, num2);
}

if (input2 == '/')
{
return divition(num1, num2);
}

if (input2 == '-')
{
return substraction(num1, num2);
}
}

multiplication(float num1, float num2)
{
return num1 * num2;
}

sum(float num1, float num2)
{
return num1 + num2;
}

divition(float num1, float num2)
{
return num1 / num2;
}

substraction(float num1, float num2)
{
return num1 - num2;
}

CalcFont()
{
cout << "---------\n";
cout << "|" << GetKey() << "       |\n";
cout << "|-------|---\n";
cout << "| 1 | 2 | * |\n";
cout << "|---|---|---\n";
cout << "| 3 | 4 | + |\n";
cout << "|---|---|---\n";
cout << "| 5 | 6 | / |\n";
cout << "|---|---|---\n";
cout << "| 7 | 8 | - |\n";
cout << "|---|---|---\n";
cout << "| 9 | C |\n";
cout << "---------\n";
}```
This are the errors I get now:

D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(26) : warning C4101: 'num1' : unreferenced local variable
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(26) : warning C4101: 'num2' : unreferenced local variable
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(29) : error C2556: 'GetKey' : overloaded functions only differ by return type
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(32) : error C2065: 'num1' : undeclared identifier
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(32) : error C2065: 'num2' : undeclared identifier
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(52) : error C2556: 'multiplication' : overloaded functions only differ by return type
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(57) : error C2556: 'sum' : overloaded functions only differ by return type
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(62) : error C2556: 'divition' : overloaded functions only differ by return type
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(67) : error C2556: 'substraction' : overloaded functions only differ by return type
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(72) : error C2556: 'CalcFont' : overloaded functions only differ by return type
Error executing cl.exe.

Calculator.exe - 8 error(s), 2 warning(s)

So, how do I make num1 and num2 to exist in the functions (I know this might be very newbish questions, but hey! I have been studying c++ for less tha 2 weeks!)

7. Follow your errors!! Include the return types in front of the names of your functions, and make sure that the functions which use the variables num1/num2 have access to them.

8. Sorry to bother all of you like this, but I am really dying here!!

Code:
```#include <iostream>
using namespace std;

//Prototypes
float GetKey(char input2);
float multiplication(float num1, float num2);
float sum(float num1, float num2);
float divition(float num1, float num2);
float substraction(float num1, float num2);
void CalcFont();

struct numbers
{
float num1;
float num2;
};

int main()
{
float input1;
char input2;
float input3;

do
{
CalcFont();
cin >> input1 >> input2 >> input3;
} while (input2 != 'c' || input2 != 'C');

return 0;
}

float GetKey(char input2)
{
numbers nums;
if (input2 == '*')
{
return multiplication(nums.num1, nums.num2);
}

if (input2 == '+')
{
return sum(nums.num1, nums.num2);
}

if (input2 == '/')
{
return divition(nums.num1, nums.num2);
}

if (input2 == '-')
{
return substraction(nums.num1, nums.num2);
}
}

float multiplication(float nums.num1, float nums.num2)
{
return nums.num1 * nums.num2;
}

float sum(float nums.num1, float nums.num2)
{
return nums.num1 + nums.num2;
}

float divition(float nums.num1, float nums.num2)
{
return nums.num1 / nums.num2;
}

float substraction(float nums.num1, float nums.num2)
{
return nums.num1 - nums.num2;
}

void CalcFont()
{
std::cout << "---------\n";
std::cout << "|" << GetKey() << "       |\n";
std::cout << "|-------|---\n";
std::cout << "| 1 | 2 | * |\n";
std::cout << "|---|---|---\n";
std::cout << "| 3 | 4 | + |\n";
std::cout << "|---|---|---\n";
std::cout << "| 5 | 6 | / |\n";
std::cout << "|---|---|---\n";
std::cout << "| 7 | 8 | - |\n";
std::cout << "|---|---|---\n";
std::cout << "| 9 | C |\n";
std::cout << "---------\n";
}```
ERRORS:
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(58) : error C2202: 'GetKey' : not all control paths return a value
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(60) : error C2143: syntax error : missing ')' before '.'
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(60) : error C2059: syntax error : '.'
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(60) : error C2059: syntax error : ')'
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(63) : error C2143: syntax error : missing ';' before '}'
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(68) : error C2143: syntax error : missing ';' before '}'
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(73) : error C2143: syntax error : missing ';' before '}'
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(78) : error C2143: syntax error : missing ';' before '}'
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(83) : error C2501: 'cout' : missing decl-specifiers
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(83) : error C2239: unexpected token '<<' following declaration of 'cout'
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(83) : error C2059: syntax error : '<<'
D:\Program Files\DevStudio\MyProjects\Calculator\Main calculator.cpp(84) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.

Calculator.exe - 12 error(s), 0 warning(s)

I would follow my errors, but trust me, I AM a newbe I dont get what is wrong, it says "missing ';' before '}' but I cant find where I a missing it!!!

9. Change all of your
Code:
```float multiplication(float nums.num1, float nums.num2)
{
return nums.num1 * nums.num2;
}```
to
Code:
```float multiplication(float num1, float num2)
{
return num1 * num2;
}```
Do this for all four calculations. This should at least fix most of your errors, although your logic is still messed up in places.

10. forget the struct, not needed.

just pass the num1, and num2, to the GetKey() function as parameters.

11. + GetKey() doesnt take 0 parameters!

12. Thanks for all of your help but I just keep getting error after error so I will throw this project to the garbage, but Thanks anyways

13. best way to get better is to debug...

14. What is debug?

15. Originally posted by Marcos
What is debug?
getting rid or errors and warnings...
it is part of learning programming, and is very crucial to being successful...