NBC 103 • Practical #11

Student Record Management with Array of Structures

Aim: To create a student record system storing Roll No, Name, Marks, and Percentage using struct.

Step-by-Step Algorithm & Logic

  • 11. Define struct Student { int roll_no; char name[40]; float marks[3]; float percentage; }.
  • 22. Create an array of struct Student s[3].
  • 33. Compute total marks and percentage for each student.
  • 44. Identify topper and display formatted tabular report card.

Complete Tested Source Code

#include <stdio.h>

struct Student {
    int roll_no;
    char name[30];
    float marks[3];
    float percentage;
};

int main(void) {
    struct Student s[3] = {
        {101, "Aman Gupta", {85, 92, 88}, 0},
        {102, "Priya Singh", {94, 96, 91}, 0},
        {103, "Rohan Verma", {78, 82, 80}, 0}
    };

    int topper = 0;
    for (int i = 0; i < 3; i++) {
        float sum = s[i].marks[0] + s[i].marks[1] + s[i].marks[2];
        s[i].percentage = sum / 3.0;
        if (s[i].percentage > s[topper].percentage) topper = i;
    }

    printf("=== BCA STUDENT REPORT CARD ===\n");
    printf("%-8s %-16s %-12s\n", "Roll No", "Name", "Percentage");
    printf("----------------------------------------\n");
    for (int i = 0; i < 3; i++) {
        printf("%-8d %-16s %-10.2f%%\n", s[i].roll_no, s[i].name, s[i].percentage);
    }
    printf("----------------------------------------\n");
    printf("🏆 Class Topper: %s (%.2f%%)\n", s[topper].name, s[topper].percentage);
    return 0;
}

Sample Input:

3 Student records with marks

Sample Output:

Class Topper: Priya Singh (93.67%)

Practical Exam Viva Questions (Exp #11)

1 Questions
1

How is an Array of Structures stored in memory?