Question
Create a program called grades.c. The program will create an array and initialize the array with the following values: 89.5, 76.2, 88.1, 39.9, 45.9, 90.1,
Create a program called grades.c. The program will create an array and initialize the array with the following values: 89.5, 76.2, 88.1, 39.9, 45.9, 90.1, 88.4, 90.2, 77.0, 63.8
These values represent the grades obtained by a class of students for a course (call this array grades).
The program must also create an initialize another integer array that will hold the registration numbers of the equivalent students that obtained the above grades. Since this is a fictitious exercise, I want you to write code that will programmatically initialize the registration numbers. Start from 20201234 and every number after that must be 100 units greater i.e. 20201334, 20201434, 20201534 and so on until 20202134. Call this array students.
Write a function called void show_grades( int g[], int s[], int size) that will be used to pass the two arrays as argument together with the size of the arrays and it will output a
listing of: [reg.no] = grade
After you create the arrays, you must write code to:
-
Show the arrays after creation using the show_grades() function.
-
Realize and output what was the
average grade of all the class.
-
Realize and output which student (with which registration number)
obtained the highest grade.
-
If the passing grade was 60, what are the percentages of students
that passed or failed the course.
-
Write code to sort the grades array in descending order (from highest to lowest), not forgetting to 'swap' the students positions to match the grades positions (i.e. highest grade at position 0, registration number of
highest grade at position 0).
-
Repeat task 1 to show the sorted
arrays
The capture on the right demonstrates a sample run.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started