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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
