# Assignment 7

This exercise is based on arrays of structures and is similar in nature to Assignment 5. You are given a list of students of the Foobarnautic Engineering department of this year together with the grades they got in each of the six courses they took in the first semester. Here is the file.

First use a structure to represent each student's data. The record should contain an integer (or string) to store the roll number of the student, a (static) array of six characters for storing the individual grades of the student and a floating point value to store the CGPA of the student.

Then use an array of student records and populate the array by reading data stored in the data file. This file stores only the grades. The CGPA is to be computed by your program. For computing the CGPA assume that the credits for the six courses are respectively 4,5,3,4,3,1. Give the standard grade points 10,9,8,7,6,5,0 for the grades Ex,A,B,C,D,P,F respectively. Then compute the CGPA based on the weighted average of the grades in individual courses.

Write two functions to sort the list of students:

• The first function should sort the list of students with respect to their roll numbers.

• The second function should sort the list of students first with respect to their CGPAs and then with respect to their roll numbers.

Sample output

Consider the following input data:

```   20
04FB1310 D D X A D A
04FB1308 B B A B C B
04FB1314 C C C A D C
04FB1306 D X C B A P
04FB1309 B C A F B A
04FB1315 F B P A D P
04FB1302 A A F C D B
04FB1317 X X A B X X
04FB1319 B D C B P D
04FB1307 D X B P D A
04FB1304 D B B B X D
04FB1305 D P B C P C
04FB1311 P X A B C C
04FB1316 B X X A B P
04FB1318 B B C C C X
04FB1301 D B D D B A
04FB1303 P B B P B C
04FB1312 A A B A A C
04FB1320 C P B D F A
04FB1313 X C B C P B
```

The corresponding output should look like:

```   List sorted by roll number:
04FB1301   D  B  D  D  B  A  6.95
04FB1302   A  A  F  C  D  B  6.75
04FB1303   P  B  B  P  B  C  6.75
04FB1304   D  B  B  B Ex  D  7.80
04FB1305   D  P  B  C  P  C  6.15
04FB1306   D Ex  C  B  A  P  7.95
04FB1307   D Ex  B  P  D  A  7.25
04FB1308   B  B  A  B  C  B  8.00
04FB1309   B  C  A  F  B  A  6.35
04FB1310   D  D Ex  A  D  A  7.35
04FB1311   P Ex  A  B  C  C  7.85
04FB1312   A  A  B  A  A  C  8.75
04FB1313  Ex  C  B  C  P  B  7.50
04FB1314   C  C  C  A  D  C  7.25
04FB1315   F  B  P  A  D  P  5.70
04FB1316   B Ex Ex  A  B  P  8.85
04FB1317  Ex Ex  A  B Ex Ex  9.45
04FB1318   B  B  C  C  C Ex  7.60
04FB1319   B  D  C  B  P  D  6.80
04FB1320   C  P  B  D  F  A  5.50

List sorted by CGPA:
04FB1317  Ex Ex  A  B Ex Ex  9.45
04FB1316   B Ex Ex  A  B  P  8.85
04FB1312   A  A  B  A  A  C  8.75
04FB1308   B  B  A  B  C  B  8.00
04FB1306   D Ex  C  B  A  P  7.95
04FB1311   P Ex  A  B  C  C  7.85
04FB1304   D  B  B  B Ex  D  7.80
04FB1318   B  B  C  C  C Ex  7.60
04FB1313  Ex  C  B  C  P  B  7.50
04FB1310   D  D Ex  A  D  A  7.35
04FB1307   D Ex  B  P  D  A  7.25
04FB1314   C  C  C  A  D  C  7.25
04FB1301   D  B  D  D  B  A  6.95
04FB1319   B  D  C  B  P  D  6.80
04FB1302   A  A  F  C  D  B  6.75
04FB1303   P  B  B  P  B  C  6.75
04FB1309   B  C  A  F  B  A  6.35
04FB1305   D  P  B  C  P  C  6.15
04FB1315   F  B  P  A  D  P  5.70
04FB1320   C  P  B  D  F  A  5.50
```

Test input

Report the output of your program on this data file.