struct anything ///44 B
{
int age; ///4 B
char name[20]; ///20 B ///member definition
char dept[10];///20 B
};
typedef struct anything newType ;
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++)
{
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);
}
}
can send me this same code in c++
ReplyDelete