-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the MrDannyClass wiki!
Read in a text file full of integer numbers separated by space or newline example:
25 -8 19 828 -77
MrDanny will provide the file and it may be of any size! Your program will take the name of the file to read as an argument on the commandline:
./assignment1 numbers.txt
The output of program will be the sum of all the numbers read, followed by the mean of the numbers, followed by the numbers that were read, in reverse order. For the input above, the output will be:
787 157.4 -77 828 19 -8 25
Where 787 is the sum and 157.4 was the mean.
HINTS: Look at the atoi() function, as well as fscanf()
Write a C program that reads in a text file (such as a book from project Gutenberg), and generates and outputs a histogram for each word found in the text. The histogram should be sorted by occurence frequency, in other words, the most commonly found word should be output first. Something like
- the: 4398
- a: 3920
- and: 3401
etc, for every word found in the file. Case shouldn't matter, so "The" and "the" should both count as "the".
By "histogram" I just mean a count for every unique word.
The name of the file to open will be passed in as the first argument to the program. So you run the program like this:
./histogram hamlet.txt
HINTS: Look up strtok(), tolower(), strcmp()