1. ## Examine my code please

I finished the new calculator

I figured out how to make it so the user could imput the signs instead of having to put 2 numbers seperated by a space.

Can you tell me waht you guys think?

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

{
return (a + b);
}
double subtract (double c, double d)//Subtraction Function
{
return (c - d);
}
double multiply (double e, double f)//Multiplication Function
{
return (e * f);
}
double divide (double g, double h)//Division Function
{
return (g / h);
}

int main ()
{
double pick1, pick2;
char choose, method;
cout << "*********************" << endl;
cout << "***The Calculator****" << endl;
cout << "**By : Ryan Nielson**" << endl;
cout << "*********************\n\n" << endl;
do
{
cout << "* to multiply or / to divide.\n " << endl;
cin >> pick1 >> method >> pick2;

cout << "\n" <<pick1 << method << pick2 << "=" << add (pick1, pick2) << endl;
else if (method == '-')//substraction
cout << "\n" <<pick1 << method << pick2 << "=" << subtract (pick1, pick2) << endl;
else if (method == '*')//multiply
cout << "\n" <<pick1 << method << pick2 << "=" << multiply (pick1, pick2) << endl;
else if (method == '/')//divide
cout << "\n" <<pick1 << method << pick2 << "=" << divide (pick1, pick2) << endl;
else
cout << "\nIncorrect input!!!!!" << endl;

cout << "\nWould you like to [c]ontinue or [e]xit: ";
cin >> choose;
}while ((choose != 'e') && (choose != 'E'));
return 0;
}```

2. formatting is a wonderful thing.

3. You mean its good or do you mean its bad :-/

4. Well with your current method of distinction between which operation they want to put on the two numbers...umm....

You don't even need all of those functions......

Why don't you go.....

Code:
```if (operator == "*")
{
cout << num1 * num2;
}```
?

5. I know I dont need all of them

I forgot to say im using this to learn functions

6. Oh, ok then In that case yes your code is quite adequite. But what I would do(personally), is put those if statements in there own function, to make main() smaller and your code easier to decipher and catch errors.

7. how would I do that?

8. >how would I do that?
Code:
```void process()
{
double pick1, pick2;
char choose, method;

do
{
cout << "* to multiply or / to divide.\n " << endl;
cin >> pick1 >> method >> pick2;

cout << "\n" <<pick1 << method << pick2 << "=" << add (pick1, pick2) << endl;
else if (method == '-')//substraction
cout << "\n" <<pick1 << method << pick2 << "=" << subtract (pick1, pick2) << endl;
else if (method == '*')//multiply
cout << "\n" <<pick1 << method << pick2 << "=" << multiply (pick1, pick2) << endl;
else if (method == '/')//divide
cout << "\n" <<pick1 << method << pick2 << "=" << divide (pick1, pick2) << endl;
else
cout << "\nIncorrect input!!!!!" << endl;

cout << "\nWould you like to [c]ontinue or [e]xit: ";
cin >> choose;
}while ((choose != 'e') && (choose != 'E'));
}```
Code:
```int main ()
{
cout << "*********************" << endl;
cout << "***The Calculator****" << endl;
cout << "**By : Ryan Nielson**" << endl;
cout << "*********************\n\n" << endl;
process();
return 0;
}```

9. after i posted that i just thought of that.
I also have to declar the pick and method variables in the processing function not in main() in order for it to work

10. >I also have to declar the pick and method variables in the processing function not in main() in order for it to work

Yes you would unless you declared an inline function.

*goes to edit his code* I had an inkling(is that the right word? lol) that there would be scope issues.

11. what i meant is that your code seems very "busy" or "cluttered". I know its not exactly what you were asking us to examine, but its the first thing i notice.

12. I would also switch those if statements to switch statements.

13. yah it was RoD
Thanks for the comment.
So I should use switch statements.
I usually dont use them unless wheres alot of choices

14. You also might consider making the code in the if's easier to read. Modify each from:
Code:
```if (method == '+')//addition
cout << "\n" <<pick1 << method << pick2 << "=" << add (pick1, pick2) << endl;
else ...```
to
Code:
```if (method == '+')//addition