--Originally published at Solving Problems with Programming
PICTURE OF AUTOR
THIS IS THE #QUIZ03 WHOSE OBJECTIVE IS CREATE AND CALL FUNCTIONS TO DO DIFFERENT TASKS AT DIFFERENT TIMES. COVERING #MASTERYTOPIC06 #MASTERYTOPIC07 .
This #QUIZ03 makes a main routine that asks the user for a number and then calls your functions to calculate the square and cube roots of that number and prints them out. And if the number given is negative. It is going to print the cube root number but in the square root it will tell the user that the number given for that root is IMAGINARY! (#Mastery11).
FIRST TO DO THIS #QUIZ03 I HAVE TO USE THE LIBRARY FOR THE COMMANDS OF MATH THAT WOULD BE SQRT FOR SQUARE ROOT AND CBRT FOR THE CUBE ROOT AND I FOUND THE NAME OF THE LIBRARY IN THE BOOK OF THE COURSE THAT IT IS CALLED #include<cmath>:
Link of the book that told me the name of the math library: How to Think Like a Computer Scientist C++ Version by Allen B. Downey.
And also for the name of the commands i used for information this link: function <cmath> cbrt and this link: function <cmath> sqrt
PICTURE OF AUTOR
PICTURE OF AUTOR
SO AT FIRST THING YOU DO THE SAME AS OTHER PREVIEW CODES DECLARATE YOUR TYPE OF VARIABLE AND YOUR VARIABLE AND ASK THE USER TO GIVE YOU A NUMBER.
AFTER THAT YOU HAVE TO CALL YOUR CREATED FUNCTIONS THAT WERE:
- double square_root(double x) {} // returns the square root of x
- double cube_root(double x) {} // returns the cube root of
YOU HAVE TO KNOW THAT USING THESE 2 FUNCTIONS IS OTHER EXTERNAL FUNCTIONS FROM THE MAIN THAT HAS A DOUBLE FUNCTION VALUE OF 64 BITS AND DECLARING A DOUBLE VARIABLE X INSTEAD OF USING THE VOID MAIN THAT HAS 0 BITS.
TO CALL THE FUNCTION IN THE MAIN
Continue reading "#Quiz03"