Friday, 29 April 2016

C Program To Create Array of Structure in C Language.

Problem :- Write A Program To Create Array of Structure in C Language.

Solution :-

#include<stdio.h>
#include<conio.h>

struct student
{
  int roll_no;
    char name[15];
};

int main()
{
  int counter;
  int size=3;
  struct student s[size];

  for(counter=0;counter<3;counter++)
  {
  printf("Enter The Name And Roll No. of Student %d\n",counter+1);
  scanf("%s%d",s[counter].name,&s[counter].roll_no); 
  }
 
printf("\n\n"); 
  for(counter=0;counter<3;counter++)
  {
  printf("Name \t%s\t Roll no. \t%d\n",s[counter].name,s[counter].roll_no);
 
}

Output :-

C Program To Create Array of Structure in C Language.

No comments:
Write comments

Recommended Posts × +