- Details
- Written by Fokwa Divine

Click on any exercise below to see the source code, program output and explanation of the code. Programs in this section make use of structures. A structure in C is a collection of one or more variables, possibly of different types, grouped together under a single name for convenient handling (K&R, The C Programming Language).

**Available Exercises**

Exercise 4.1. Using structures, write the necessary declaration for Employees in a company.

Exercise 4.2. Using structures, write the necessary declarations and functions for implementing addition, subtraction, multiplication and division of complex numbers.

Exercise 4.3. Using structures, write the necessary declarations for Customers in a typical credit union in Cameroon.

Exercise 4.4. Using structures, write a simple declaration for students in a university.

Exercise 4.5. Using structures, write a simple declaration for teams in the Cameroon football league.

Exercise 4.6. Write a structure declaration for a straight line and a function which, given the coordinates of a point on the line and its gradient, displays the equation of the line.

Equation of a straight-line: y = mx + c

Exercise 4.7. A survey of 10 Hip-Hop / R&B records is made. Each person votes by specifying 3 values (between 1 and 10) representing their choice of first, second and third. The first choice scores 4 points, the second 2 and the third 1 point. Using structures, write a program to read the data, process the votes and display the most popular record. Appropriate validations should be incorporated into the program (A person cannot vote the same record twice).

Exercise 4.8. Using structures, write the necessary declaration for information about books in a library.