Chapter 3.9 - More Mathematical Library Functions C++
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.
sqrt (area)
Write the necessary preprocessor directive to enable the use of functions like sqrt and sin.
#include <cmath>
Write the necessary preprocessor directive to enable the use of the rand function.
#include <cstdlib>
Write the necessary preprocessor directive to enable the use of the time function.
#include <ctime>
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.
sqrt((pow(a, 2)) + (pow(b,2)))
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.
sqrt(pow((sqrt(area)), 2) + pow((sqrt(area)) , 2))
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.
sqrt(pow(length, 2) + pow(width, 2))