Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
1
Indexable
Never
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
    int grades[12][6][2];
    int i, j, k;
    
    char* subjects[] = {"English", "Math", "Bengali", "Science", "Social Science", "Computer Science"};
    
    // Initialize the array with random values between 50 and 100
    srand(time(NULL));
    for (i = 0; i < 12; i++) {
        for (j = 0; j < 6; j++) {
            for (k = 0; k < 2; k++) {
                grades[i][j][k] = rand() % 51 + 50;
            }
        }
    }
    
    // Find the lowest grade of each student in each subject and print the results
    printf("%-20s", "Subjects");
    for (i = 0; i < 12; i++) {
        printf("Student %d ", i+1);
    }
    printf("\n");
    for (j = 0; j < 6; j++) {
        printf("%-20s", subjects[j]);
        for (i = 0; i < 12; i++) {
            int lowest_grade = grades[i][j][0];
            for (k = 1; k < 2; k++) {
                if (grades[i][j][k] < lowest_grade) {
                    lowest_grade = grades[i][j][k];
                }
            }
            printf("%-10d ", lowest_grade);
        }
        printf("\n");
    }
    
    return 0;
}