#include <isostream>
#include <math>
#include <stdlib>
int main()
{
using namespace std;
int selection(0);
double input1(0.0);
double input2(0.0);
char indicator('n'
;
cout << "Welcome to the C++ Calculator" << end1;
for (;
{
cout << "please choose the operation that you want: "
<< end1
<< "1 addition" << end1
<< "2 subtraction" << end1
<< "3 multiply" << end1
<< "4 division" << end1
<< "5 square root" << end1
<< "6 power" << end1
<< "0 exit" << end1
<< end1
<< "enter your selection number: ";
cln >> selection;
switch (selection)
{
case 1: cout << end1 << "enter the frist number to add: ";
cln >> input;
cout << end1 << "enter the second number: ";
cln >> input2;
cout << end1 << "the sum of" << input1 << " and " << input2 << " is " << input + input2 << end1;
break;
case 2: cout << end1 << "enter the frist number to subtract: ";
cln >> input;
cout << end1 << "enter the second number: ";
cln >> input2;
cout << end1 << "the difference between" << input1 << " and " << input2 << " is " << input - input2 << end1;
break;
case 3: cout << end1 << "enter the frist number to multiply: ";
cln >> input;
cout << end1 << "enter the second number: ";
cln >> input2;
cout << end1 << "the product of" << input1 << " and " << input2 << " is " << input * input2 << end1;
break;
case 4: cout << end1 << "enter the frist number to divide: ";
cln >> input;
cout << end1 << "enter the second number: ";
cln >> input2;
cout << end1 << "the quotient of" << input1 << " and " << input2 << " is " << input / input2 << end1;
break;
case 5: cout << end1 << "enter the number you want to find the square root of: ";
cln >> input;
cout << end1 << "the square root of" << input1 << " is " << sqrt(input1) << end1;
break;
case 6: cout << end1 << "enter the base: ";
cln >> input;
cout << end1 << "enter the exponent: ";
cln >> input2;
cout << end1 << input1 << "to the power of" << input2 << "is equal to" << pow(input1, input2) << end1;
break;
case 0: exit(exit_success);
break;
default: cout << end1 << "the selection number you have entered is invalid" << end1;
break;
}
cout << end1 << "would you like to perform another calculation? (y or n): ";
cln >> indicator;
if((indicator == "n") || (indicator == "n"))
break;
}
return 0;
}
;
;
|| (indicator == 'n'
)
#include <isostream>
#include <math>
#include <stdlib>
int main()
{
using namespace std;
int selection(0);
double input1(0.0);
double input2(0.0);
char indicator('n'
;
cout << "Welcome to the C++ Calculator" << end1;
for (;
{
cout << "please choose the operation that you want: "
<< end1
<< "1 addition" << end1
<< "2 subtraction" << end1
<< "3 multiply" << end1
<< "4 division" << end1
<< "5 square root" << end1
<< "6 power" << end1
<< "0 exit" << end1
<< end1
<< "enter your selection number: ";
cln >> selection;
switch (selection)
{
case 1: cout << end1 << "enter the frist number to add: ";
cln >> input;
cout << end1 << "enter the second number: ";
cln >> input2;
cout << end1 << "the sum of" << input1 << " and " << input2 << " is " << input + input2 << end1;
break;
case 2: cout << end1 << "enter the frist number to subtract: ";
cln >> input;
cout << end1 << "enter the second number: ";
cln >> input2;
cout << end1 << "the difference between" << input1 << " and " << input2 << " is " << input - input2 << end1;
break;
case 3: cout << end1 << "enter the frist number to multiply: ";
cln >> input;
cout << end1 << "enter the second number: ";
cln >> input2;
cout << end1 << "the product of" << input1 << " and " << input2 << " is " << input * input2 << end1;
break;
case 4: cout << end1 << "enter the frist number to divide: ";
cln >> input;
cout << end1 << "enter the second number: ";
cln >> input2;
cout << end1 << "the quotient of" << input1 << " and " << input2 << " is " << input / input2 << end1;
break;
case 5: cout << end1 << "enter the number you want to find the square root of: ";
cln >> input;
cout << end1 << "the square root of" << input1 << " is " << sqrt(input1) << end1;
break;
case 6: cout << end1 << "enter the base: ";
cln >> input;
cout << end1 << "enter the exponent: ";
cln >> input2;
cout << end1 << input1 << "to the power of" << input2 << "is equal to" << pow(input1, input2) << end1;
break;
case 0: exit(exit_success);
break;
default: cout << end1 << "the selection number you have entered is invalid" << end1;
break;
}
cout << end1 << "would you like to perform another calculation? (y or n): ";
cln >> indicator;
if((indicator == "n") || (indicator == "n"))
break;
}
return 0;
}
Copyright © 2026, NextGenUpdate.
All Rights Reserved.