Given the following struct: typedef struct { char surname[MAX], name[MAX]; int id; float avg; // average score: a value between 18 and 30 (may have fractional digits) } student_t;

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section: Chapter Questions
Problem 6PP
icon
Related questions
Question
This is not a graded question so please don't disregard it as if it is.Thank you in advance professor! Note: Everything should be coded in C AND NOT C++
Given the following struct:
typedef struct {
char surname[MAX], name[MAX];
int id;
float avg; // average score:
a value between 18 and 30 (may have fractional digits)
} student t;
A) Write a function mostFrequent that, given an aIray of students s and its dimension n, returns the most frequent average score, ie.,
the average score associated with the highest number of students in the array. The returned value should be an integer between 18 and 30
(included). The function should have the following prototype:
int mostFrequent (student t s[U, int n);
In case of parity, the function should retum the average with the highest value.
Example If the average scores of the given students are 18.3, 22.1, 28.7, 21.9 the function should return the value 22.
B) Write a second function printStudents that, given an array of students s, its dimension n and an average score selectAvg (for
example, it could be the result returned by the function mostFrequent)prints the ID of all the students with that average. The function
should have the following prototype.
void printStudents (student_t s[0, int n, int selectAvg);
NB When assigning a student to a certain average score, you should round the average score of the student to the closest integer (0.5 is
rounded to 1). This applies to both the functions mostFrequent and printStudents.
Example: 24.7 is rounded to 25; 21.3 is rounded to 21; 29.5 is rounded to 30.
Transcribed Image Text:Given the following struct: typedef struct { char surname[MAX], name[MAX]; int id; float avg; // average score: a value between 18 and 30 (may have fractional digits) } student t; A) Write a function mostFrequent that, given an aIray of students s and its dimension n, returns the most frequent average score, ie., the average score associated with the highest number of students in the array. The returned value should be an integer between 18 and 30 (included). The function should have the following prototype: int mostFrequent (student t s[U, int n); In case of parity, the function should retum the average with the highest value. Example If the average scores of the given students are 18.3, 22.1, 28.7, 21.9 the function should return the value 22. B) Write a second function printStudents that, given an array of students s, its dimension n and an average score selectAvg (for example, it could be the result returned by the function mostFrequent)prints the ID of all the students with that average. The function should have the following prototype. void printStudents (student_t s[0, int n, int selectAvg); NB When assigning a student to a certain average score, you should round the average score of the student to the closest integer (0.5 is rounded to 1). This applies to both the functions mostFrequent and printStudents. Example: 24.7 is rounded to 25; 21.3 is rounded to 21; 29.5 is rounded to 30.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Structure chart
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning