First, your code is a good effort for a beginner :+) , so well done!
Some minor things to add:
It is always
int main()
not
void main()
Prefer to declare functions before main, then define them after main.
Use
double
rather than
float
.
float
has only 7 or 8 significant figures of precision - this is easily exceeded.
double
has 15 or 16.
You had a
const
value for PI , but didn't use it on line 40.
Every beginner seems to forget to check for divide by zero. Be careful with that - check if the absolute value of the number is less than some arbitrary precision 0.0001 say.
Always put a default case in a switch - use it to catch bad input or error conditions.
I am not a fan of multiple statements on one line.
Always initialise variables - this is one of the biggest source of errors. Do this at declaration, one per line plus a comment, especially if it is only 1 char long - say what it means and it's use and the expected valid range or values. Try to use meaningful names wherever you can.
There is an
*=
operator for multiplication. There are a lot of these assignment operators - look them up in the tutorial.
You don't need line 8 if you are going to qualify std namespace things as in
std::cout
. Line 8 is bad practice, qualifying things with
std::
is good practice.
Hope this helps and good luck - look forward to seeing your revised code.