Question: Write a C program named sort.c . The program should include a function named selection _ sort ( ) . selection _ sort should take

Write a C program named sort.c. The program should include a function named selection_sort(). selection_sort should take two arguments: the first argument should be an int array and the second argument should be an int representing the array size. The function should return void. It should sort the input array using the selection sort algorithm.
Your main method should demonstrate that your selection_sort() function works on several input arrays (for example, by printing the array before and after the sort).
Ensure that your submitted selection_sort function does not print anything (print only in main or helper functions called in main).
Write a C program named rainfall.c. The program should prompt the user to enter daily rainfall totals, one per line, until they enter -1. The program should also accept the value T for a "trace" (negligible amount) of rainfall. After the user enters the values, the program should print the total rainfall with two digits to the right of the decimal point. Count T as 0.0. You can assume that the input rainfall totals will be a non-negative int or float with a value less than 10 and with no more than two digits to the right of the decimal point (or T or -1). You must use getchar(), not functions such as scanf or getint that we haven't seen yet. Your rainfall.c file should not depend on any other files. An example run is shown below (user input is in quotations):
"b$ gcc rainfall.c"
"$ ./a.out"
Enter daily rainfall totals, one per line, use 'T' for trace, use '-1' to quit:
"9.99
0.01
1.2
0
4
T
-1"
Total rainfall: 15.20
Hint: the function atof is similar to atoi but returns a double instead of an int. It is included in stdlib.h. You can look up this function and use it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!