#include <iostream>
#include <cmath>
using namespace std;
int main() {
// Your code goes here
float num1, num2, result;
int input;
cout << "Basic Calculator based on input \n 1 for Addition, \n 2 for Subtraction, \n 3 for Multiplication, \n 4 for Division, \n 5 for Power" << endl;
cout << "Enter the first number: ";
cin >> num1;
cout << "Enter the second number: ";
cin >> num2;
cout << "Enter the input: ";
cin >> input;
if(input == 1){
result = num1 + num2;
}
else if (input == 2){
result = num1 - num2;
}
else if(input == 3){
result = num1 * num2;
}
else if(input == 4){
if(num2 == 0){
cout << "Cannot divide by 0" << endl;
return 1;
}
else{
result = num1 / num2;
}
}
else if(input == 5){
result = pow(num1, num2);
}
else{
cout << "Invalid input" << endl;
return 1;
}
cout << "The result is " << result << endl;
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: