Arrays allow defining types of variables that can hold several data items of the same kind. Similarly, the structure is another user-defined data type available in C that allows combining data items of different kinds.

syntax :

struct [structure_Name] 

{

         member definition;   

         member definition;

         ...

         member definition; 

};

Declaration of Structures :

struct student 
     char student_name[50]; 
     int student_id[50];     
     
}; 

Example :

#include <stdio.h> 
#include <conio.h> 
#include<string.h>
struct student 
char student_name[50];
Int student_id[50];
}; 
int main( ) 
struct student std1;
strcpy(std1.student_name,"Ram");
Std1.student_id=12345;
Printf(“Student Name =%s”,student_name);
Printf(“Student ID =%d”,student_id);

return 0; 

Watch the Video Lecture



            Previous                                                                                                                       Next