Question: The function MUST HAVE THE FOLLOWING PROTOTYPE: void selection_sort(struct torus array_tori[], int n); Write a program that sorts the tori (multiple torus) by volume. The

The function MUST HAVE THE FOLLOWING PROTOTYPE: void selection_sort(struct torus array_tori[], int n);

Write a program that sorts the tori (multiple torus) by volume. The major radius and minor radius will be read from file tori.txt. Write the sorted torus, including volumes to a text file called sorted.txt. Assume tori.txt has the format of minor radius (double) followed by major radius (double) with each torus on a separate line: 12.2 23.4

Name your program tori.c.

The program should be built around an array of structures, with each structure containing information of a toruss major radius, minor radius, and volume. Assume that there are no more than 1000 tori in the file.

Use fscanf and fprintf to read and write data.

Modify the selection_sort function provided to sort an array of product struct. The tori should be sorted by volume in ascending order.

Output the sorted cylinders, including volume, in a text file called sorted.txt, in the following format.

Expected in sorted.txt:

# minor_rad major_rad Volume

1 1.400000 10.400000 402.364032

2 3.000000 6.400000 1136.978427

3 2.400000 12.000000 1364.374112

4 3.500000 6.500000 1571.734501

5 2.800000 10.600000 1640.407208

6 4.100000 5.600000 1858.170160

7 3.400000 8.200000 1871.119081

8 3.500000 12.400000 2998.385817

9 3.400000 14.200000 3240.230603

10 4.500000 12.300000 4916.543432

11 7.800000 14.200000 17053.255182

12 9.100000 10.500000 17163.340750

13 9.800000 12.500000 23696.920167

14 9.400000 15.600000 27208.841240

15 10.200000 14.200000 29162.075430

16 12.400000 14.400000 43705.450734

17 13.400000 18.200000 64507.576452

18 12.200000 23.400000 68748.821812

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 Databases Questions!