Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Introduction [cont'd]
Input Output Functions [cont'd]
Structures and Unions [cont'd]
# Preprocessor [cont'd]
Arrays of Structures in Structures and Unions of Programming in C
2147 Views
Arrays of Structures 
Structure object is also use as array in c.

Thus,
struct student stud_object[10];
Program
	#include
	struct student{
	   int rno;
	   char name[20];
	};
	void main(){
	   struct student stu[4];
	   int i;
	    //Reading data for structures
	   for (i=0;i<4;i++){
	       printf("Enter the rno:");
	       scanf("%d",&stu[i].rno);
	       printf("Enter the name:");
	       scanf("%s",&stu[i].name);
	  }
	   //Print structure
	   for (i=0;i<4;i++){
	       printf("%d : %s\n",stu[i].rno,stu[i].name);
	   }
	}
Output 
Enter the rno:1001
Enter the name: Anthony
Enter the rno:1002
Enter the name: David
Enter the rno:1003
Enter the name: Manikandan
Enter the rno:1004
Enter the name: Rajeswari

1001 : Anthony
1002 : David
1003 : Manikandan
1004 : Rajeswari
Next Topics
Next lessons of current book.
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Previous Topics
Previous lessons of current book.
Structures and Unions of Programming in C
Structures and Unions of Programming in C
Structures and Unions of Programming in C
User-defined Functions of Programming in C
User-defined Functions of Programming in C
Best Lessons of "Programming in C"
Top lessons which are viewed more times.
Structures and Unions of Programming in C
Input Output Functions of Programming in C
Structures and Unions of Programming in C
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details