Question: 1 Census Data De ne the following data type that contains US State information. typedef struct f char State Name [20]; double Total Area ;

1 Census Data De ne the following data type that contains US State information. typedef struct f char State Name [20]; double Total Area ; double Water Area ; double Land Area ; int Population ; int Population per Land Area ; g State ; Develop a C program that reads a le called State Data.txt into a 10-element array of type State. The le State Data.txt contains the name of the state, the population in the state, the total area of the state in square miles, and the area that is covered in water (also in square miles). You will need to calculate population per land area (rounded to the nearest person per square mile). Note that the land area is the total area minus the area covered in water. The program then prints the states sorted by population per square mile. Your program should use the following functions: void scan states ( State x, FILE in ); void print states ( State x); File State Data.txt: Georgia 10450316 59425.15 1911.66 Texas 28449186 268596.46 7364.75 Arizona 7026629 113990.30 396.22 Florida 21002678 65757.70 12132.94 California 39849872 163694.74 7915.52 Pennsylvania 12819975 46054.35 1311.64 Illinois 12815607 57913.55 2394.62 Michigan 9935116 96713.51 40174.61 Virginia 8492783 42774.93 3284.84 Washington 7384721 71297.95 4842.43 1 Sort the array of states in terms of population per square mile, then print the sorted array to the screen. The following functions will sort an array of type int. Modify these functions to receive State, and operate on State. void selection ( int x[], int size ) f // selection sort int i, j; int min ; for (i = 0; i < size ; i ++) f min = i; // start searching from currently unsorted for (j = i; j x[ min ]) // if found a smaller element min = j; // move it to the front g swap (&x[i], &x[ min ]); g g void swap ( int x, int y) f int temp ; temp = x; x = y; y = temp ; g HINT: The swap function protocol should be void swap ( State x, State y); And the if statement in selection should be if(x[j]. Population per Land Area > x[ min ]. Population per Land Area )// if found Expected Output Florida has 392 people per square mile of dry land Pennsylvania has 287 people per square mile of dry land California has 256 people per square mile of dry land Illinois has 231 people per square mile of dry land Virginia has 215 people per square mile of dry land Georgia has 182 people per square mile of dry land Michigan has 176 people per square mile of dry land Washington has 111 people per square mile of dry land Texas has 109 people per square mile of dry land Arizona has 62 people per square mile of dry land

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!