Program for Arrays of Structures in C
Subject: PPS (Programming for Problem Solving)
Contributed By: Sanjay
Created At: February 3, 2025
Question:
Write an Example Program for Arrays of Structures in C.
Explanation Video:

Explanation:
- Array of structures allows storing multiple records of the same structure type.
This is useful for handling multiple students, employees, or products in an organized way
Source Code:
#include <stdio.h>
struct Employee {
char name[50];
int id;
float salary;
};
int main() {
struct Employee employees[3] = {
{"Alice", 101, 50000},
{"Bob", 102, 55000},
{"Charlie", 103, 60000}
};
printf("Employee Details:\n");
for (int i = 0; i < 3; i++) {
printf("Name: %s, ID: %d, Salary: %.2f\n", employees[i].name, employees[i].id, employees[i].salary);
}
return 0;
}
Output:
Employee Details:
Name: Alice, ID: 101, Salary: 50000.00
Name: Bob, ID: 102, Salary: 55000.00
Name: Charlie, ID: 103, Salary: 60000.00