Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Tuesday, October 4, 2022

Print array elements in tabular form using structure in C programming

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();

}


Output:



No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages