Getting Started With C

Definition:

An array of structures in C is a data structure that allows you to group multiple variables of different data types under a single name.

            

Syntax:

Declare a structure: struct structure_name { data_type member1; data_type member2; // ... more members }; Declare an array of structures: struct structure_name array_name[size];

Explanation:

Each element of the array is a structure, and you can access its members using the dot operator (.). Arrays allow you to store and manipulate multiple instances of the same structure type.
  • Examples :

    Program.c


  •         

    Output

    Enter name, roll number, and marks for student 1: John 101 85.5 Enter name, roll number, and marks for student 2: Alice 102 78.5 Enter name, roll number, and marks for student 3: Bob 103 92.0 Student Information: Name: John, Roll Number: 101, Marks: 85.50 Name: Alice, Roll Number: 102, Marks: 78.50 Name: Bob, Roll Number: 103, Marks: 92.00 This program demonstrates the use of an array of structures to store and display information about students.

    Resources :

    Test Your Knowledge
    Choose The

    With supporting text below as a natural lead-in to additional content.

    Q1. What is the purpose of using arrays of structures in C?

    Q2. If you have an array of Book structures named library, how would you access the title member of the second book in the array?