Problem: Write a C program to read and print students’ details using structure.

We will use an array of structure objects to store the details of multiple students in C.

Each Structure (i.e. Student) will have:

  • Name
  • Roll
  • Stream

For the demonstration purpose, we will read 2 student’s details, store them in the array, and finally print it.

Output:

Student details using structure in C Output-min

Student students[n] is the array declaration of the Student type. It means each element in the array holds the details of a particular student.

The value of n determines the number of students details the array can have.

Using the ‘for’ loop, we input the details of n students and output the same in the structured format.

Note: After every input, we have used scanf("%c", &buffer) to catch automatic insertion of the null value.

In this programming example, we learned to read and store students’ details using the structure in C. Comment below your suggestions.

Leave a Reply

16 − three =