×
☰ Menu

Example of Structure

 

Code: 

#include <stdio.h>
#include <string.h>
struct Student {
   int rollno;
   char subject[100];
   int CGPA;
} 
Student1,Student2,Student3,Student4;  
int main( ) {
   Student1.rollno=158;
   strcpy( Student1.subject, "FOCP");
   Student1.CGPA=8;
   printf( "Book 1 title : %d\n", Student1.rollno);
   printf( "Book 1 subject : %s\n", Student1.subject);
   printf( "Book 1 book_id : %d\n", Student1.CGPA);
   return 0;
}

 

Output: 

Book 1 title : 158
Book 1 subject : FOCP
Book 1 book_id : 8

--------------------------------
Process exited after 2.869 seconds with return value 0
Press any key to continue . . .