Question: C Code - Sorting Skeleton Code: // sortModules.c // Given an array of module codes, and an array of student // enrolment, sort the modules
C Code - Sorting

Skeleton Code:
// sortModules.c // Given an array of module codes, and an array of student // enrolment, sort the modules in ascending order of // student enrolment. #include#include #define MAX_MODULES 10 // maximum number of modules #define CODE_LENGTH 7 // length of module code typedef struct { char code[CODE_LENGTH+1]; // module code int enrolment; // enrolment } module_t; int scanModules(module_t []); void printModules(module_t [], int); void sortByEnrolment(module_t [], int); int main(void) { module_t modules[MAX_MODULES]; int num_modules; num_modules = scanModules(modules); sortByEnrolment(modules, num_modules); printModules(modules, num_modules); return 0; } // Read number of modules, and for each module, the module codes and enrolment figures. // Return number of modules. int scanModules(module_t modules[]) { int size, i; printf("Enter number of modules: "); scanf("%d", &size); printf("Enter module codes and student enrolment: "); for (i=0; i Test Data: http://www.comp.nus.edu.sg/~cs1010/practice/2017s1/Practice-S12P02/testdata/
Objective: Sorting Task statement Given an array of module_t variables with the following structure definition: typedef struct t char code [CODE LENGTH+1] int enrolment; l module t; Your task is to sort the modules in ascending order of student enrolment using Selection Sort Bubble Sort or Insertion Sort. You may assume that there are at most 10 modules and a module code contains at most 7 characters Sample run Enter number of modules 10 Enter module codes and student enrolment: CS1010 292 CS1234 178 CS1010E 358 CS2102 260 IS1103 215 IS2104 93 IS1112 100 GEK1511 83 IT2002 51 MA1101S 123 Sorted by student enrolment: IT2002 51 GEK1511 83 IS2104 93 IS1112 100 MA1101s 123 CS1234 178 IS1103 215 CS2102 260 CS1010 292 CS1010E 358
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
