Three function Calculator 2.0 A week ago I did a three function calculator, I took the input from you guys and made it better. Overall it works fine, I didn't find any problems. But as a beginning programer I'd like some input on this calculator.

// Three function Calculator.cpp : main project file.
#include "stdafx.h"
#include&lt;iostream&gt;
using std::cout;
using std::cin;

long double action(long double num1, long double num2, char act) //External function to do all the calculations
{
    long double total;
    switch (act)
    {
    case '+':
        total = num1 + num2;
        break;
    case '-':
        total = num1 - num2;
        break;
    case '*':
        total = num1*num2;
        break;
    case '/':
        total = num1 / num2;
        break;
    default:
        cout &lt;&lt; "Input not recognized\n";
    }
    return total;    //Giving the main function a number to work with.
}

int main()
{
    cout &lt;&lt; "Enter action as # to exit program\n";
    cout &lt;&lt; "Possible actions:+,-,*,/\n\n";
    long double num1, num2, num3, total;
    char act1, act2;
    while (1)   //inf loop
    {
        beginning:    //label, to reset the program in case of division by zero
        cin &gt;&gt; num1 &gt;&gt; act1 &gt;&gt; num2 &gt;&gt; act2 &gt;&gt; num3;
        if (act1 == '#' || act2 == '#')         //user wants to exit program
        {
            system("pause");
            return 0;
        }
        else if (act1 == '/' &amp;&amp; num2 == 0 || act2 == '/' &amp;&amp; num3 == 0)      //division by zero happens
        {
            cout &lt;&lt; "You can't divide by zero\n";
            cout &lt;&lt; "\n\n";
            goto beginning;              //restarting the program from the lable, to the beginning of the 'while' loop
        }
        else if ((act2 == '*' || act2 == '/') &amp;&amp; (act1 == '-' || act1 == '+'))     //action2 happens before action1 because of order of operation
        {
            total = action(num2, num3, act2);             //sending the function reciving the total
            total = action(num1, total, act1);            //sending the total of previos function to get overall total
        }
        else      //action1 happens before action2 because of order of operation
        {
            total = action(num1, num2, act1);      //sending the function reciving the total
            total = action(total, num3, act2);     //sending the total of previos function to get overall total
        }
        cout &lt;&lt; num1 &lt;&lt; act1 &lt;&lt; num2 &lt;&lt; act2 &lt;&lt; num3 &lt;&lt; "=" &lt;&lt; total;   //printing result of overall function
        cout &lt;&lt; "\n\n";    //new line before restarting program
    }
}


Old Calculator



Example:


  Input:-6*2+4
  Output:-6*2+4=-8
A couple quick things to make maintenance easier:

It's easier to work out where you're going if you use continue instead of the goto. If you do keep the goto, I'd at least edit the comment to refer to the beginning of the while loop instead of a specific line number. That will change if you have to change something, and you don't want to have to remember to update the comment.

In terms of readability, when checking for order of operations, you could do something like

if (precedence(act2) &gt; precedence(act1))


Then it would be easier if you wanted to add an exponent operator.