Question
Write a C program that opens a text file called numbers.txt for reading. The file contains a sequence of integers all separated by new lines.
Write a C program that opens a text file called numbers.txt for reading. The file contains a sequence of integers all separated by new lines. Your program should read all of the numbers in the file and output the following information: A count of the number of integers read. The sum of all the integers in the file. The smallest integer in the file. The largest integer in the file. The average of all the numbers.
I ran the program with the following input file.
7
4
3
5
-20
1
9
87
32
41
9001
File location: To test your program, you can use an absolute path (full path) for the text file like what I had in the class. When you submit your program, just use ?numbers.txt? (remove any path information) in fopen function. If you know the location of your executable program, you can copy the numbers.txt file to that directory. Your program output should look something like the following:
is 9170. There were 11, integers in the file. The sum of all the integers in, the fi The smallest integer in the file is The largest integer in the file is 2001 The average of the numbers 13 833.636364. all is Press any key to continue.
Step by Step Solution
3.45 Rating (148 Votes )
There are 3 Steps involved in it
Step: 1
include int main FILE fp int numisumminmax double a...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started