Squares & Cubes

Picture by Unsplash Unsplash

 

In this Quiz we had to make a main routine that asked for a number and showed the square and cubic roots of that number and printed them. We had to be careful, cause we had to give a message in our square root if the number given was negative.

This is my code: (also see it on GitHub)

Captura de pantalla 2017-01-31 a la(s) 10.11.22.png

There are several things we had to do in this quiz: (there are different ways we could do this, I made it this way)

  • We had to include our library cmath, for our functions square_root and cubic_root, and of course they had to return both sqrt(x) and cbrt(x).
  • I made if’s functions, if the number given was smaller than cero, it will give the advice that de square root couldn’t be done because the number was negative, it would give the cubic root and also gives the opportunity to give another number, a positive one (that was made with a do-while function. If the number was bigger than cero, we were good to go and it would give us all the answers and it would close.

If you have any questions feel free to ask.

 

L.out

 

Deja un comentario