Untitled

 avatar
unknown
plain_text
2 years ago
2.2 kB
2
Indexable
#include <stdio.h>
#include <string.h>

#define MAX_STUDENTS 50

// Define the structure to store student details
struct student {
    char name[50];
    int roll_no;
    char dob[15];
    int marks;
};

// Function to generate the list of marks alone from the given data and display the list
void generate_marks_list(struct student students[], int num_students) {
    printf("Marks List\n");
    for(int i=0; i<num_students; i++) {
        printf("%d\n", students[i].marks);
    }
}

// Function to combine the rank lists of both classes in ascending order
void combine_rank_lists(struct student students_a[], int num_students_a, struct student students_b[], int num_students_b) {
    struct student all_students[MAX_STUDENTS];
    int num_all_students = num_students_a + num_students_b;

    // Combine the students of both classes
    for(int i=0; i<num_students_a; i++) {
        all_students[i] = students_a[i];
    }
    for(int i=0; i<num_students_b; i++) {
        all_students[num_students_a+i] = students_b[i];
    }

    // Sort the students in ascending order of their marks
    for(int i=0; i<num_all_students-1; i++) {
        for(int j=0; j<num_all_students-i-1; j++) {
            if(all_students[j].marks > all_students[j+1].marks) {
                struct student temp = all_students[j];
                all_students[j] = all_students[j+1];
                all_students[j+1] = temp;
            }
            else if(all_students[j].marks == all_students[j+1].marks) {
                if(strcmp(all_students[j].dob, all_students[j+1].dob) > 0) {
                    struct student temp = all_students[j];
                    all_students[j] = all_students[j+1];
                    all_students[j+1] = temp;
                }
            }
        }
    }

    printf("Combined Rank List\n");
    printf("Rank\tRoll No\tName\t\tMarks\n");
    for(int i=0; i<num_all_students; i++) {
        printf("%d\t%d\t%s\t%d\n", i+1, all_students[i].roll_no, all_students[i].name, all_students[i].marks);
    }
}

// Function to display the class average and student details who have secured marks less than the class average under each class
void display_class_average_and_below_average_students
Editor is loading...