Worksheet Structure
Worksheet Structure
1. Write a functions InputData and DisplayData that reads and display the elements of a
record(structure). Use the student record defined below.
struct Student{
char name[20];
char sex;
int age;
};
2. Use the functions in problem number 1 to read and display a list of students record.
Modify the display function so that it displays the list in a tabular form. Add another
function to your program in problem number 2 which can display only the list of female
or male students depending on the user choice.
3. A student record consist of his id number, a list of marks, average mark, and his rank.
struct Student{
unsigned id;
float marks[5];
float average;
unsigned rank;
};
use the above structure to write a program that can read the inputs (id number and list of
marks) for the students in a class and calculate the average mark for each student. Your
program should finally give the rank for each student. Write a function that displays the
list of students in the order of their rank
4. Write a program which defines a new structure type to contain the following information
about towns: the name (a sequence of characters); the population (an integer); and a
Boolean value (i.e. true or false) which indicates whether the town has an airport or not.
Use the typedef statement to define your own Boolean data type -remember that true
in C++ is equivalent to the integer value 1, and false is equivalent to 0.
5. Declare a single structure data type suitable for an employee record of the type illustrated
below:
Number Name Rate Hours
3462 JONES 4.62 40
6793 Robbins 5.83 38
7834 Swain 6.89 40
9002 Williams 4.75 42
Using the data type declared above, write a C++ program that interactively accepts the
above data into an array of six structures. Once the data have been entered, the program
should create a payroll report listing each employee’s name, number, and gross pay.
Include the total gross pay of all employeesat the end of the report.