Print array elements in tabular form using structure in C programming
#include<stdio.h>
#include<conio.h>
main()
{
struct student
{
char name[20];
char add[20];
int age;
}a[5];
int i;
for(i=0;i<5;++i)
{
printf("Enter name:");
scanf("%s",a[i].name);
fflush(stdin);
printf("Enter address:");
scanf("%s",a[i].add);
printf("Enter age:");
scanf("%d",&a[i].age);
}
printf("\n\n");
printf("Name\tAdress\t\tAge\n");
for(i=0;i<5;++i)
printf("%s\t %s\t\t %d\n",a[i].name,a[i].add,a[i].age);
getch();
}
No comments:
Post a Comment