I just started writing C++ and i only know the basics, if there is anyway to improve my simple caluculator or if you have any functions I could add to it let me know. Here is the code I wrote feel free to take bits.
#include <cstdlib>
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
int main()
{
double num;
double num2;
char choice;
const double PI = 3.141592;
for (;;){
do {
cout<<"Welcome to then Calculator.\n";
cout<<"Please choose an option by entering the number, press q to quit\n";
cout<<"1 - Addition\n";
cout<<"2 - Subtraction\n";
cout<<"3 - Division\n";
cout<<"4 - Multiplication\n";
cout<<"5 - Square root\n";
cout<<"6 - Area of a circle\n";
cin>>choice;
} while ( choice < '1' || choice > '7' && choice != 'q');
if (choice == 'q') break;
switch (choice) {
case '1':
cout<<"Please enter a number\n";
cin>>num;
cout<<"Another number to be added\n";
cin>>num2;
cout<< "Your answer is equal to " <<num + num2;
cout<<"\n";
break;
case '2':
cout<<"Please enter a number\n";
cin>>num;
cout<<"Another number to be subtracted\n";
cin>>num2;
cout<<" Your answer is equal to " <<num - num2;
cout<<"\n";
break;
case '3':
cout<<"Please enter a number\n";
cin>>num;
cout<<"Another one to be divided\n";
cin>>num2;
cout<< " Your answer is equal to " <<num / num2;
cout<<"\n";
break;
case '4':
cout<<"Please enter a number\n";
cin>>num;
cout<<"Another one to be multiplied\n";
cin>>num2;
cout<< "The product of your two numbers is equal to " << num * num2;
cout<<"\n";
break;
case '5':
cout<<"Please enter your number\n";
cin>>num;
cout<<"The Squre root of your number is equal to " << sqrt(num);
cout<<"\n";
break;
case '6':
cout<<"Please enter the radius of your circle in meters.\n";
cin>>num;
cout<<"The area of your circle is equal to "<<pow(num,2)*PI <<"M^2";
cout<<"\n";
break;
default:
cout<<"That is not an option";
}
}
return 0;
}