#include <iostream>
using namespace std;
int main()

{
    char function;
    double num1, num2;
    char option;
    option = 'y';
    
    cout << " Please enter two numbers:  ";
    cin >> num1 >> num2;
    cout << "\n  + for addition ";
    cout << "\n  - for subtraction ";
    cout << "\n  * for multiplication ";
    cout << "\n  / for division " << endl;
    cout << "\n Select an operation to perform from the list above: ";
    cin >> function;

    switch ( function )
        do 
        {
            {
                case '+':
                    cout << "\n " << num1 << " + " << num2 << "  is your equation " << endl;
                    cout << "\n The sum of your numbers is  " << num1 + num2 << endl;
                    break;
                case '-':
                    cout << "\n " << num1 << " - " << num2 << "  is your equation " << endl;
                    cout << "\n The difference of your numbers is  " << num1 - num2 << endl;
                    break;
                case '*':
                    cout << "\n " << num1 << " * " << num2 << "  is your equation " << endl;
                    cout << "\n The product of your numbers is  " << num1 * num2 << endl;
                    break;
                case '/':
                    cout << "\n " << num1 << " / " << num2 << "  is your equation " << endl;
                    cout << "\n The dividend of your numbers is  " << num1 / num2 << endl;
                    break;
                default:
                    cout << "\n You failed to select from the table provided " << endl;
            }
            while ( option == 'y' )
            cout << "\n Would you like to perform another calculation? " << endl;
            cin >> option;
            break;
        }
   cout << "\n I hope this helped ";
   return 0;
}

this is not home work directly i am trying to add a loop to the already existing HW which is math function aspect. i cant seem to figure out how to just make a simple Yes or No loop. i have no problem making the loop if it needs to count... any way any one have any suggestions on how to help a newbie?

thanks in advance!

put the do in before this line:

cout << " Please enter two numbers: ";

and the while after the closing brace of the switch statement.

} //end of switch statement
cout << "\n Would you like to perform another calculation? " << endl;
cin >> option;
}while ( option == 'y' );

hahahahaha, i knew it was something silly, thank you very much...this was killing me. thank you!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.