Question: 6. (a) Define a structure named Student in C that contains the following members, (5) (1) 40 element character array named name (ii) An integer

6. (a) Define a structure named Student in C that contains the following members, (5) (1) 40 element character array named name (ii) An integer named dept Code (iii) An integer named id (iv) A floating point variable named cgpa (b) Using the structure defined in 6(a), write a function void sort (struct Student S[], int n). This function will sort the array of Students in ascending order of their dept Code. Additionally, students with equal dept Code need to be sorted among them in ascending order of their id. (15) (c) Assume that a file named input.txt contains information about the students. The first line of the file represents the number of students, n. Then follows n lines each containing the name, deptCode, id and cgp of a student (separated by spaces). Using the structure defined in 6(a), write a program to (7+1+7=15) (i) Read the information of students from the file. (ii) Sort them with the help of the function in 6(b). (iii) And then write the sorted list in a file named "output.txt
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
