CCS0007 - Laboratory Exercise 4
CCS0007 - Laboratory Exercise 4
CCS007L
(COMPUTER PROGRAMMING 2)
EXERCISE
4
STRUCTURES
Section:
Professor:
I. PROGRAM OUTCOME/S (PO) ADDRESSED BY THE LABORATORY EXERCISE
• Apply knowledge through the use of current techniques and tools necessary for the IT
profession. [PO: I]
struct MyStructure {
Members
};
A structure can be thought of as an object without any member functions. The important
property of structures is that the data in a structure can be a collection of data items of diverse
types.
A structure variable can hold values just like any other variable can. A structure value is a
collection of smaller values called member values.
int main()
{
database employee;
employee.age = 22;
employee.id_number = 1;
employee.salary = 12000.21;
}
Structures are used to represent a record, suppose you want to keep track of your books in
a library. You might want to track the following attributes about each book:
• Title
• Author
• Subject
• Book ID
To access any member of a structure, we use the member access operator (the dot
operator). The member access operator is coded as a period between the structure variable
name and the structure member that we wish to access. You would use struct keyword to
define variables of structure type.
Write a C++ program to keep records and compute for the scores of 5 players. The
information of each player contains: Nickname, Age and two best played scores.
The program will prompt the user to choose the operation of records from a menu as
shown below:
==============================================
MENU
==============================================
1. Add record
2. View players records
3. Compute for the average
4. Show the player(s) who gets the max average.
5. Show the player(s) who gets the min average.
6. Exit
Briefly answer the questions below. Avoid erasures. For group activity, specify the name of
GROUP MEMBER/s who answered the question. Do not forget to include the source for all
NON-ORIGINAL IDEAS.