Write a C program to enter student details(name, register number, age) using array of structures.

 C PROGRAM TO ENTER STUDENT 

DETAILS


PROGARM

#include<stdio.h>
#include<conio.h>
int n,i;
struct student
{
    char name[20];
    int regnumber,age;
};
struct student st[100];
void readlist()
{
    for(i=0; i<n; i++)
    {
        printf("Enter the name of the student \n");
        scanf("%s",&st[i].name);
        printf("Enter the register number and age\n");
        scanf("%d%d",&st[i]. regnumber,&st[i].age);
      }
}
void display()
{
    for(i=0; i<n; i++)
    {
        printf("\n Name =%s",st[i].name);
        printf("\n register number=%d", st[i]. regnumber);
        printf("\n age=%d \n",st[i].age);
   
}
}
void main()
{
    struct student st[100];
    clrscr();
    printf("Enter number of students;\n");
    scanf("%d",&n);
    readlist();
    printf("\n \t<< students record>>");
    display();
    getch();


OUTPUT

<< students record>>
 Name =bala
 register number=80
 age=18


 Name =guna
 register number=96
 age=18
[Process completed (code 10) - press Enter]

No comments:

Post a Comment




Copyright Ⓒ 2022 | Mechpedia | All Right Reserved.