How would you write out the code using switch statements to get the same output. If you can, please write a comment next to the lines changed to provide a brief explanation of what that line does. I am a beginner and looking to learn more about this language.
Thanks in advance!
What advantage would using an array give you over what you currently have?
About the sole advantage I can see is the ability to keep a history of what choices were made. The program would not be enhanced as written using an array.
Since the number of iterations is variable -- the user requests as many or as few calculations as they want -- I would use a std::vector over a regular sized-at-compile-time array. https://en.cppreference.com/w/cpp/container/vector
One change I would make that could streamline the program is using a switch statement instead of so many ifs. A switch would make adding new choices much easier. https://en.cppreference.com/w/cpp/language/switch
I would also declare PI as a constant since the value should not be alterable.
Thank you for the clarification. I seem to have mistaken arrays for switch statements. I was thinking about ways to use less ifs and thought the way to fix that was using arrays.
I could write the code for you, but you'll learn more if you make the attempt first yourself. If you are still stuck post the updated code and we can help.