Andrew H.

asked • 01/17/21

C Programming (Prompt and attempt at solution)

The program expects the name of an input file and an output file to be given by the user. If

the user does not input any names, default file names should be used, such as input.txt

and output.txt. The input files have lines which look like this:

3 Tester College; 1909 33001

The first number represents the rank; it is followed by the school name, year founded,

and approximate number of students.

Read the list of colleges into an array of structures. You may assume that the maximum

size of a college name string is 64.

The program should use either the insertion sort algorithm or the selection sort algorithm

to sort the array in descending order by rank.

Display any k consecutive schools requested by the user. For instance, if the user enters 1

2, the program displays the first 2 schools in a readable format of your choice. If the user

enters 1 5, the program displays the first five schools, if the user enters 2 7, display 7

schools beginning with the one at index 1 (2 - 1), and so on. Repeat this process until the

user enters 0 0. Reject invalid input (such as -1 5, or 1 200, etc.)

Finally write the sorted array to the output file, using the same format as in the input

file’s format.

Run the program once and save the screen output at the end of the source file as a

comment.

input.txt

3 Tester College; 1929 33001

5 Aponoeo College; 1964 22300

9 Arizona College; 1942 4000

7 Westside College; 1972 9506

2 Apollo College; 1917 25300

8 Sidester College; 1947 4760

4 Diablo Valley College; 1939 24781

6 Foothill College; 1947 18362

1 College of the Herch; 1957 24712

10 Quelsa College; 1953 19571



Andrew H.

https://docs.google.com/document/d/1BKQ9dpyTjJ4AOXI1UH7z2X3lApJUzb-qc-bJ3X323AA/edit?usp=sharing
Report

01/17/21

1 Expert Answer

By:

Patrick B. answered • 01/17/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Andrew H.

I have sent you an email. Thank you for your time
Report

01/17/21

Patrick B.

I just realized I compiled as C++... I changed the file to *.C and recompiled.. mostly errors with loop counter vars in for loops... I reposted the source code IN C, not c++ I apologize
Report

01/17/21

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.