How tall is a
Because of the way
in which light is refracted by water droplets, the angle
between the level of your eye and the top of the rainbow
is always the same. If you know the distance to the
rainbow, you can multiply it by the tangent of that angle
to find the height of the rainbow.
The magic angle is
The C++ standard
library works in radians, so you may have to convert the
angle to radians with the formula:
Radians = degrees x
pi/180 (where pi = 3.14159265)
Through the header
file cmath, the C++ standard library provides a tangent
function named tan. This is a value returning function
that takes a floating-point argument and returns a
To determine the
height of the rainbow, multiply the tangent by the
distance to the rainbow.
Write a program to
determine the height of a rainbow.
Please prompt the judge to
enter the distance to the rainbow (in meters) as shown
Enter the distance to
the rainbow (in meters): 52
You can assume that:
The value entered will be
a number, and
The value will be an
integer (the judge will not enter a decimal number, i.e.
After reading the
distance to the rainbow, determine the height of the
rainbow and print it out to 4 decimal places.
The height of the
rainbow is 47.3717 meters.