In order to motivate the use of conditional statements in C, we will study the
problem of a block sliding down a ramp.
The diagram shows a block sitting on a ramp that is inclined from the
horizontal at an angle . Let's ignore any friction between the block
and the ramp for the moment. The block is initially prevented from moving, but
at time t = 0 it is released. The block will now slide down the ramp,
accelerating as it goes. The steeper the ramp, the faster the block will go.
In fact, the acceleration due to gravity of the block is
meters/sec/sec, where g is the earth's gravitational constant. Since the
block is not initially moving, the distance that the block will slide in t
seconds is given by
(You may recognize this as the familiar ``one-half-a-t-squared'' formula from
introductory physics.) Notice that the distance moved by the block depends
upon both t and . Why is that?
Click here for the answer
Joseph L. Zachary
Hamlet Project
Department of Computer Science
University of Utah