0
1.7kviews
Define a structure consisting of following elements

a. Student roll_no

b. Student name

c. Student percentage

Write a program to read records of 5 students and display same.

Subject : Structured Programming Approach

Title : Arrays, String, Structures and Union

Difficulty : Medium

1 Answer
0
67views

Program:

#include<stdio.h>
#include<conio.h>

struct Student {
    char name[50];
    int rn;
    float p;
} s[100];

int main() {
    int i, j, n;
    float p1;
    clrscr();

    printf("\n\n\t Enter total records");
    scanf("%d", &n);

    for(i=0; i<n; i++) {
        fflush(stdin);

        printf("\n\n\t Please enter the name");
        gets(s[i].name);

        printf("\n\n\t Please enter roll no.");
        scanf("%d", &s[i].rn);

        printf("\n\n\t Please enter percentage");
        scanf("%f", &p1);

        s[i].p = p1;
    }

    printf("\n\n\t Student records");

    for(i=0; i<n; i++) {
        printf("\n\n\t Name => %s", s[i].name);
        printf("\n\n\t Roll No. => %s", s[i].rn);
        printf("\n\n\t Percentage => %s", s[i].p);
    }

    getch();
    return 0;
}
Please log in to add an answer.