Skip links

编程代写|COSC2666 Programming Second Semester 2021 C Programming Assignment



This assignment contributes 20% towards your assessment for Programming and will be
given a mark out of 40 as shown in brackets to the right of the instructions.

It must be your own independent work. You may not hire another author or copy another
person’s work.

Your assignment must not be submitted as a pair or group effort.

The program must be written in C, not C++ or any other language.

You will present, for assessment:

• your C code,
• a working exe program and
• a pdf document with screen shots of the displayed table of heights after you have
entered data for ten objects and have run the program using test data generated by
the program.

The scenario

You are a researcher who will choose ten tall or high objects to study. You will enter data based on a
survey of each object and you will create a C program that takes this data and outputs some useful
information about the vertical height of each.

The input data will be the results of a survey that measures the angles between the top and the base
of each object with respect to the horizontal. To make the calculation work, record angle above the
horizontal as positive and any below as negative. You will also record your horizontal distance from
the object, which would normally have been made either by using either a tape measure or a map.

You do not have to make actual measurement. The data does not have to be actual but should be

I am going to use an eagles’ nest as an example. (Do not use Eagles’ nests as the subject of your

The Australian Wedge Tailed Eagle was once a hunted a pest because it preyed on lambs and other
small farm animals. Now this magnificent bird is protected.

For the safety of the chick and so that the parents have a good view of the surrounding countryside,
the nest is generally built at as great a height as possible, a high cliff or at the top of a tall tree,
The nest can have a mass of up to 400kg. Researchers find nests difficult to access.

The researcher depicted above (not the rabbit), measures the angle T between the horizontal and
the nest, then measures the angle B between the horizontal and base of the tree. *Se makes the
angle B negative (-) since it is below the horizontal. Se measures the horizontal distance D to the

The height H of the nest above the base of the tree can be found using the function (formula)
H = D[tan(angle T) – tan(angle B)] For example, if D = 100m, Angle T = 30o, Angle B = 20o (below horizontal) H = 100[tan(30oπ/180) – tan(-20oπ/180)]
= 94.1m.

Note that both angles have been converted to radians.

The function works the same way even if both angles are above the horizontal or both are below.
Just remember to make any angle below the horizontal negative. Remember to convert degrees to
radians for the C formula tan() to work. The formula will work happily on bridges buildings,
mountains, aerials, aircraft in flight etc.