CS35: Assignment 17

CS35: Programming and Problem Solving
Ray Ontko
Department of Computer Science
Earlham College

Due Wednesday, 1999/11/03

Reading Assignment

Read sections 6.1 through 6.4 in Deitel and Deitel. Optionally, read section 1.6 in Kernighan and Ritchie.

Programming Exercise

Write a program which reads input and produces a histogram representing line-lengths for the input file. You may assume, for simplicity, that all input lines will have fewer than 100 characters.

For example:

$ cat panama.txt
a man
a plan
a canal
panama
$ ./line_hist < panama.txt
0
1
2
3
4
5 *
6 **
7 *

Maximum length = 7

For fun, modify the program to do something reasonable if there are lines having 100 or more characters.

Copyright © 1999, Ray Ontko (rayo@ontko.com).