Search This Blog

Wednesday, 2 March 2022

B9. C Program to demonstrate student structure to read and display records of n students.

 // B9. C Program to demonstrate student structure to read and display records of n students.
#include<stdio.h>
#include<conio.h>

struct student
{
    char name[20];
    int age;
    char city[20];
};

void main()
{
    struct student s[10];
    int i, n;
    clrscr();

    printf("\nEnter the number of students \n");
    scanf("%d",&n);

    printf("\nEnter details of %d student(s):\n",n);

    for(i=0;i<n;i++)
    {
        printf("\nEnter Name, age and city of %d student: \n",i+1);
        scanf("%s%d%s",&s[i].name,&s[i].age,&s[i].city);
    }
    printf("\nThe details of students: \n");
    printf("Name \t Age \t City \n");
    printf("==== \t === \t ==== \n");
    for(i=0;i<n;i++)
        printf("%s \t %d \t %s \n",s[i].name,s[i].age,s[i].city);

    getch();
}


No comments :

Post a Comment

FREE Hit Counters