Chapter 3.9 – More Mathematical Library Functions C++ – Flashcards
Unlock all answers in this set
Unlock answersquestion
Write the necessary preprocessor directive to enable the use of functions like sqrt and sin.
answer
#include
question
The area of a square is stored in a double variable named area. Write an expression whose value is length of one side of the square.
answer
sqrt (area)
question
If a right triangle has sides of length A, B and C and if C is the largest, then it is called the "hypotenuse" and its length is the square root of the sum of the squares of the lengths of the shorter sides (A and B). Assume that variables a and b have been declared as doubles and that a and b contain the lengths of the shorter sides of a right triangle: write an expression for the length of the hypotenuse.
answer
sqrt((pow(a, 2)) + (pow(b,2)))
question
The area of a square is stored in a double variable named area. Write an expression whose value is length of the diagonal of the square.
answer
sqrt(pow((sqrt(area)), 2) + pow((sqrt(area)) , 2))
question
The length of a rectangle is stored in a double variable named length, the width in one named width. Write an expression whose value is the length of the diagonal of the rectangle.
answer
sqrt(pow(length, 2) + pow(width, 2))
question
Write the necessary preprocessor directive to enable the use of the rand function.
answer
#include
question
Write the necessary preprocessor directive to enable the use of the time function.
answer
#include