This is a multi-part question. Write all three parts in the text box below, as if in one single C
source code file. Don’t include anything that cannot be compiled. You do NOT have.to #include,
but you can use any standard C library function that appears on the C reference sheet.
Any assumptions should be explained in comments. (Legal C comments, not just text. A
Copyright By PowCoder代写 加微信 powcoder
comment begins with // on every line, or is surrounded by /* */.)
(15 pts) Define a C struct that can be used to represent an ingredient in a recipe. You must
include the ingredient, the amount to use, and the unit of measurement. When allocated, the
struct must be self-contained; do not rely on information being stored elsewhere in memory.
(10 pts) Define a C function that will print an array of ingredients to the standard output stream,
one per line. You must use the struct definition from the first part.
• (15 pts) Define a C function that will sort an array of ingredients, alphabetically, using the
selection sort algorithm. You must use the struct definition from the first part, and you must
use the selection sort algorithm
Suppose you have opened a file that contains only integers, where every integer is followed by
either a single space or a linefeed. The number of integers in the file is unknown, and there is no
maximum limit.
You are supposed to write a function that computes the sum of all of those integers. Which of
the following alternatives will compute the correct sum? There may be more than one correct
solution- check them all for full credit.
Select one or more:
int sum(FILE *fp) {
int s = 0;
int x = 0;
while (!feof (fp)) {
fscanf (fp, “%d”, &x);
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com