SemSure
←
Programming for Problem Solving · Unit 5: Structures, dynamic memory and files

Structures and arrays of structures (employee records)

BL 3 · ApplyScenario likelyNew in R2026New in R2026 · syllabus practice (Unit 5, S1–S4)
✓ 0/3
1What is it

A structure groups different types under one name: an employee's id (int), name (char array) and salary (float) become one record. An array of structures stores many records.

Remember
struct Employee { int id; char name[30]; float salary; };
struct Employee e;      e.salary = 50000;   /* dot for a variable */
struct Employee *p = &e; p->salary = 60000; /* arrow for a pointer */

Opens chatgpt.com in a new tab with a ready-made prompt for this topic.

Watch it on YouTube
2Understand it
Three employee records share the same layout, with separate fields for ID, name and salary.Employee arrayIDNameSalary
Each position in the array holds one complete employee record.
  • Use staff[i].salary to access the salary in record i.
  • Passing a structure by value gives the function a copy. Store the returned copy to keep a change.
  • Passing &staff[i] lets the function use -> to update the original.
3Solve a practice question
Syllabus guided practice · search and update a record15 marksBL 3 · Apply

Store three employee records (ID, name, salary) in an array of structures. Search an employee by ID. Give a 10% raise with a function that takes the structure by value and returns the updated structure, then set the salary with a function that takes it by reference.

Try it on paper first. Then check each step.