A program to explain ARRAY of structures
C Programming Language 093
- Write a program to explain ARRAY of structures
Program
#include <stdio.h>
struct student
{
char name[15];
int rn;
};
void main()
{
struct student s[3];
int i;
for (i = 0; i < 3; i++)
{
printf("Enter name and roll number: ");
scanf("%s %d", &s[i].name, &s[i].rn);
}
printf("\n====Student Details====\n");
printf("Name:\t\tRoll no.");
for (i = 0; i < 3; i++)
{
printf("\n%-15s %-4d", s[i].name, s[i].rn);
}
printf("\n");
}
Result
Enter name and roll number: Alice 12
Enter name and roll number: Bob 34
Enter name and roll number: Carol 56
====Student Details====
Name: Roll no.
Alice 12
Bob 34
Carol 56
Last Updated on
Comments