Categorize students according to their marks

To categorize students according to their marks in C, you can follow these steps:

  1. Declare and initialize an array to store the marks of the students. For example:
int marks[] = {80, 65, 90, 70, 50};
  1. Calculate the total number of students. This can be done using the sizeof operator divided by the size of an individual element. For example:
int numStudents = sizeof(marks) / sizeof(marks[0]);
  1. Create separate arrays to store the categories of students based on their marks. For example, if you want to categorize students as "Excellent," "Good," "Average," and "Poor," you can declare arrays for each category:
int excellent[numStudents];
int good[numStudents];
int average[numStudents];
int poor[numStudents];
  1. Iterate through the marks array and assign each student to the appropriate category based on their marks. You can use conditional statements (if-else or switch-case) to determine the category. For example:
int excellentCount = 0;
int goodCount = 0;
int averageCount = 0;
int poorCount = 0;

for (int i = 0; i < numStudents; i++) {
    if (marks[i] >= 90) {
        excellent[excellentCount] = marks[i];
        excellentCount++;
    } else if (marks[i] >= 70) {
        good[goodCount] = marks[i];
        goodCount++;
    } else if (marks[i] >= 50) {
        average[averageCount] = marks[i];
        averageCount++;
    } else {
        poor[poorCount] = marks[i];
        poorCount++;
    }
}
  1. After categorizing the students, you can print the marks for each category. For example:
printf("Excellent students:\n");
for (int i = 0; i < excellentCount; i++) {
    printf("%d ", excellent[i]);
}

printf("\n\nGood students:\n");
for (int i = 0; i < goodCount; i++) {
    printf("%d ", good[i]);
}

printf("\n\nAverage students:\n");
for (int i = 0; i < averageCount; i++) {
    printf("%d ", average[i]);
}

printf("\n\nPoor students:\n");
for (int i = 0; i < poorCount; i++) {
    printf("%d ", poor[i]);
}
  1. Finally, you may want to consider sorting the arrays in ascending or descending order before printing the marks to display them in a more organized manner. This can be achieved using sorting algorithms like bubble sort or insertion sort.

Remember to include the necessary header files and function prototypes, and to provide appropriate error handling and validation based on your specific requirements.