int main ()
cin >> x;
switch ( x <= 3 )
cout << x * x << endl; //when x is less than or equal 3 it squares x
cout << sqrt(x) << endl; //when x is 20 it square roots the function
This is similar to what I compile, i do use the cin >> x; as well and do have a basic understanding of the math functions and C++ layout, I am also assuming that what my instructor wants is something involving recursion as well. I was also thinking of trying to call the functions using void and call them in the main() body. Any feedback is appreciated, thanks.
I know it does seem impractical to use the switch this way but I cannot think of a way to apply the loop continuation conditions to shorten it. I was able to get it to work using static_cast<int> for the testing value in my switch. If interested I will try to post my instructors method of the solution. I appreciate the help, thanks!!