struct anything ///44 B
{
int age; ///4 B
char name[20]; ///20 B ///member definition
char dept[10];///20 B
};
typedef struct anything newType ;
void display(int num,int i,newType student[])
{
printf(" Info of student %d : \n",i+1);
printf("Name = ");
puts(student[i].name);
printf("Age = %d\n",student[i].age);
printf("Dept = ");
puts(student[i].dept);
}
main()
{
printf("Enter student number ");
int num;
scanf("%d",&num);
newType student[num];
int i;
for(i=0 ; i<num ; i++)
{
printf(" Info of student %d : \n",i+1);
printf("Name = ");
getchar();
gets(student[i].name);
printf("Age = ");
scanf("%d",&student[i].age);
printf("Dept = ");
getchar();
gets(student[i].dept);
}
for(i=0 ; i<num ; i++)
{
display(num,i,student);
}
}
No comments:
Post a Comment