0% found this document useful (0 votes)
22 views7 pages

Vadodara Institute of Eng.: Computer Programming and Utilization

This document discusses arrays of structures in C programming. It defines a structure called "student" with fields for ID, name, and percentage. It then declares an array of this student structure with size 2, and populates the fields for 3 student records. A for loop is used to print out the details of each student record in the array. The output displays the ID, name, and percentage for each of the 3 students.

Uploaded by

Jayesh Nakiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views7 pages

Vadodara Institute of Eng.: Computer Programming and Utilization

This document discusses arrays of structures in C programming. It defines a structure called "student" with fields for ID, name, and percentage. It then declares an array of this student structure with size 2, and populates the fields for 3 student records. A for loop is used to print out the details of each student record in the array. The output displays the ID, name, and percentage for each of the 3 students.

Uploaded by

Jayesh Nakiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

VADODARA INSTITUTE OF ENG.

COMPUTER PROGRAMMING
AND UTILIZATION

- PROF.VISHAL ANDODARIYA

 BHOSLE JAY J. (17MECH013)


 SHETHVALA MD.SAFI S. (17MECH014)
 NAKIYA JAYESH (17MECH015)
ARRAY OF STRUCTURES

• C Structure is collection of different data types (variables )


which are grouped together.

• Whereas, array of structures is nothing but collection of


structures. This is also called as structure array in C.
ARRAY OF STRUCTURE VARIABLE

• A struct in the C programming language is a composite data type


declaration that defines a physically grouped list of variables to be placed
under one name in a block of memory, allowing the different variables to be
accessed via a single pointer, or the struct declared name which returns the
same address
SYNTAX
struct structure_name structure_variable[ ];

Example:
struct student S1,S2,S3,S4,….,S60;
OR
struct student S[60];
Struct student
{
     int id;
     char name[30];
     float percentage;
};
 
int main()
{
     int i;
     struct student record[2];
 
     // 1st student's record
     record[0].Id=1;
     strcpy(record[0].Name, "raju");
     record[0].Percentage = 86.5;
 
     // 2nd student's record        
     record[1].Id=2;
     strcpy(record[1].Name, "surendren");
     record[1].Percentage = 90.5;
 
     // 3rd student's record
     record[2].Id=3;
     strcpy(record[2].Name, "thiyagu");
     record[2].Percentage = 81.5;
 
     for(i=0; i<3; i++)
     {
         printf("     records of STUDENT : %d \n", i+1);
         printf(" id is: %d \n", record[i].Id);
         printf(" name is: %s \n", record[i].Name);
         printf(" percentage is: %f\n\n",record[i].Percentage);
     }
     return 0;
OUTPUT:
Records of STUDENT : 1
Id is: 1
Name is: Raju
Percentage is: 86.500000
Records of STUDENT : 2
Id is: 2
Name is: Surendren
Percentage is: 90.500000
Records of STUDENT : 3
Id is: 3
Name is: Thiyagu
Percentage is: 81.500000

You might also like