A program that prints the ids and scores of all 10 students

Assignment Help Computer Engineering
Reference no: EM132211291

Question :

Write a program (in Q1.c) in which you consider the following structure:

struct student { int id; int score; };

Implement the following functions and demonstrate their functionality using the calls already existing in main():

Write a function struct student* allocate() that allocates a contiguous chunk of memory for 10 students and returns the pointer.

Write a function void generate(struct student* students) that populates the id and score fields of the array of 10 students passed as an argument. Each student should have an id that corresponds to their index in the array (i.e. the first student in the array should have id 0). If each student's id is x, the student's score should be (10 * x) % 50.

Write a function void output(struct student* students) that prints the ids and scores of all 10 students.

Write a function float avg(struct student* students) that computes the average of all scores.

Write a function int min(struct student* students) that computes the minimum of all scores.

Write a function void deallocate(struct student* stud) that frees the memory allocated to students. Check that students is not NULL (NULL == 0) before you attempt to free it.

Write a function void sort(struct student* stud) that sorts students by descending score (i.e. highest scores at the top). You must sort the array in-place - that is, you should not allocate any additional memory. You may not use C sorting routines like qsort(). You must implement the sort yourself.

Reference no: EM132211291

Questions Cloud

What is timex charitable contribution deduction : What is Timex’s charitable contribution deduction for the current year and is there a charitable contribution carryover available to the following year?
A program that prompts the user to enter an integer number : Write a program that prompts the user to enter an integer number between 0 and 1000 and adds all the digits in the integer.
Identify many milestones in operations management : we can identify many milestones in operations management that have re-shaped how products were made and how services were delivered.
Because of the fact that human resource management : Because of the fact that human resource management are placing more emphasis on increasing service oriented training of employees on the job
A program that prints the ids and scores of all 10 students : Write a function struct student* allocate() that allocates a contiguous chunk of memory for 10 students and returns the pointer.
How does racial and cultural awareness impact effectiveness : How does racial and cultural awareness impact the effectiveness of various stakeholders, including those providing direct care to the needs of their service.
Examining the point in terms of behavioral analysis : Since this research question is examining the point in terms of behavioral analysis this can be best answered by using a qualitative method.
Students are required to critique two peer drafts : Students are required to critique two peer drafts, providing substantive feedback and discussion.
Did you find yourself having any predispositions : Did you find yourself having any predispositions about any of the religions/holidays you reviewed and are those biases taken into the workplace.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write a program to initialize an arraylist of strings

Write a program to initialize an ArrayList of Strings and insert ten words. Then, using Math.random, print two different Strings from the list.

  Questionq1 assume that the ith operation on a data

questionq1 assume that the ith operation on a data structure takes thetaui time where ui is the number of units in the

  What are the nine rules of thumb for selecting indexes

What are the nine rules of thumb for selecting indexes for the relational database? Provide a brief description of each rule.

  How that film represents contribution to field of cyber law

Using a Microsoft Word document, please review movie ( War Games (1983) ) and tell how that film represents a contribution to the field of Cyberlaw.

  What characteristic in the data to perform compression

Can you compress a set of bank statements using JPEG compression? MP3, JPEG, and MPEG all rely on what characteristic in the data to perform compression?

  Create an application that lets user enter number of books

Create an application that lets the user enter the number of books that he or she has purchased this month and displays the number of points awarded.

  Explain how you would meet each requirement

The company locations should be connected to each other via a WAN that supports ALL types of traffic generated at each office.

  How to handle performance deterioration in wlan

South West State University installed a series of 4 Wi-Fi omni-directional APs (access points) spread across the ceiling of the key floor of their library.

  Create a package diagram of the problem domain layer

Create a package diagram of the problem domain layer using the communication diagrams and the CRUDE matrix through the use of graphical tools

  What kind of mitigations would you recommend for protection

Why was it so much more effective than previous BotNet designs? What kind of mitigations would you recommend for protection?

  How many comittees are possible

The States of California, Arizona, New Mexico, Utah, and Nevada each send a team of 6 delegates to the Sounth Western States annual conference.

  Calculate and plot the error of the forward difference

Write a MATLAB function which calculates and plots the error of both the forward and central difference approximations of the first derivative of a polynomial.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd