C Programming

SEQUENCE STATEMENTS PRACTICAL QUESTIONS

1

You have been tasked with writing code to calculate the kinetic energy of a body.

Following the software development process, perform the following:

(a)

Write an algorithm to calculate the kinetic energy of a body.

(b)

Draw a flowchart to represent the algorithm.

(c)

Write a pseudocode to represent the algorithm.

(d)

Implement the algorithm

Note: The kinetic energy is calculated using the formula KE = 1 2 mv2, where KE is the kinetic energy, m is the mass and v is the velocity.

2

You have been tasked with writing code to calculate the potential energy of a body.

Following the software development process, perform the following:

(a)

Write an algorithm to calculate the potential energy of a body.

(b)

Draw a flowchart to represent the algorithm.

(c)

Write a pseudocode to represent the algorithm.

(d)

Implement the algorithm

Note: The potential energy is calculated using the formula PE = mass x acceleration due to gravity x height, where PE is the potential energy, m is the mass, g is the acceleration due to gravity, and h is the height.

Acceleration due to gravity (g) = 9.8 m/s2