Question: ICS 103-172 Lab Test 4 Section 62 Student Student | 2 osu (296? ID Name Write a complete C program that reads from a file
ICS 103-172 Lab Test 4 Section 62 Student Student | 2 osu (296? ID Name Write a complete C program that reads from a file named Population.txt and writes into a file named Summary.txt. The structure of the Population.txt - which contains unknown number of countries - is as follows: Each line contains three values: The first letter of a country, the population size of the year 2010, and population size of the year 2015. The program must contain two functions: the main and the ComputeStatisties. In the main function, prompt and read a character from the user. Then, it calls the function ComputeStatistics with this letter as an argument. In addition, the main function writes() the country letter, (ii) the population difference of the two years and (ii) the percentage of the population growth into the file summary.txt. The function Compute Statistics receives the letter and computes the difference between the two population values and the percentage of the population growth of the target country. The difference and the population growth percentage are computed by the following formulas: PopulationDiff = NewPopulation-old Population PopulationDiff PopulationGrowtholdPopulation 100 Very important notes: (1) Declare Compute Statistics function that returns more than one result. (2) Using array is not allowed. (3) Manipulating files should be done using loop. output file: Summary.txt Population differences of country K is 2500000 Population growth percentage is 83.33% Input file: Population.tt 8000000 J 5000000 ? 1300000 3600000 K 3000000 5500000 s 8000000 12000000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
