Question: ET2100 You have been given a file containing two numbers per line. The first number represents the low temperature recorded for the day and the
ET2100
You have been given a file containing two numbers per line. The first number represents the low temperature recorded for the day and the second the high temperature for the day. This means that you will be doing fscanf into two different variables. (And it also means that there will be two of other variables as well, such as separate sum variables for the low and the high temperatures.)
Remember that
- You will need to declare a FILE * variable to work with the file
- You will need to open the file for reading with the fopen function
- fscanf works the same as scanf except that its first argument is a FILE pointer
- fscanf returns the number of items successfully read in, 0 if unsuccessful and -1 if it has reached the end of the file
For all of this stuff you can look at temps.txt
Your program is to find
- The number of temperature pairs (days) in the file
- The average of all the low temperatures
- The average of all the high temperatures
- The hottest temperature recorded in the time period in question
- The coldest temperature in the time period in question
At the end of your program have it write a nicely formatted report with the information requested above. Be sure to close the file. Once you are happy with the output, start a script called report.txt, run your program one more time and then use ctrl-d to end the script.
Here is all the data in temps.txt
53 84 48 81 58 73 57 65 51 68 52 85 51 74 56 85 48 77 48 68 53 72 62 77 54 68 54 79 49 70 59 79 41 84 50 73 49 75 48 62 59 82 60 77 46 76 60 73 41 80 48 70 43 73 57 84 45 69 56 63 46 69 46 68 61 65 39 67 44 72 61 84 41 74 61 68 43 63 52 68 62 68 40 62 55 81 46 63 39 67 47 67 48 74 58 75 41 65 47 63 57 65 57 83 45 85 41 67 41 84 58 62 56 72 48 84 43 72 55 71 59 64 53 83 56 68 46 85 45 63 52 76 49 70 51 67 47 66 54 82 40 81 44 71 61 69 39 79 46 79 42 85 42 75 56 78 52 83 44 75 50 65 60 84 61 69 53 84 47 66 45 80 40 73 58 63 47 66 62 73 41 70 39 71 50 85 40 70 62 80 42 75 55 63 40 77 44 80 44 78 54 68 61 71 58 74 54 62 44 63 45 72 50 76 55 70 61 77 46 82 61 83 49 78 59 65 39 65 62 63 59 72 50 72 39 70 52 68 54 83 62 85 51 62 51 81 42 74 49 68 50 82 50 75 56 84 49 64 50 70 52 65 56 84 53 79 43 69 48 63 42 80 45 67 41 73 59 78 56 76 56 65 44 69 43 80 56 85 54 68 41 62 52 79 52 72 54 81 57 75 53 77 44 76 55 82 47 75 42 82 40 82 50 69 43 77 58 75 41 81 51 68 60 71 56 79 55 70 54 77 40 82 44 83 50 78 62 65 44 82 56 78 43 77 61 71 57 65 46 75 50 72 49 72 42 82 55 68 40 76 59 75 57 80 51 67 45 79 56 81 57 63 62 73 57 76 51 63 43 64 47 65 52 66 47 81 44 64 49 68 41 68 55 83 51 71 60 84 60 80 55 73 54 82 50 75 50 81 58 62 52 83 61 76 55 71 61 78 50 63 46 63 55 76 56 79 40 85 53 71 40 71 50 73
**Can you show me how to do this particular example? I am getting stuck on the whole loop subject part of this. Make sure that this is in Programming in C language as well. Thank you!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
