CS 246 (Programming Paradigm)
Project #2
Due:
Saturday, Feb 8, 2014 by 11:59pm
The purpose of this assignment is to get
you started in writing programs in C.
Using only the features of C you have learned in so far write a C program that takes text as input, and outputs the following:
the number of lines in the input
the number of characters in the input
the number of words in the input
All characters, including the newline ('\n'), should be counted.
Assume that only space(s), newline characters, and tab characters seperate words. That is: ' ', '\n', and '\t'.
Input is terminated by entering CTRL-D at any time.
Instead of typing long paragraphs to test your program, you can use text file using I/O redirection. I/O redirection on Unix converts text files to standard input for programs. For example, if the text is stored in a file, textinput, you can input it into the program (a.out) by using I/O redirection as follows:
$ ./a.out < textinput
The results will then be printed on the screen. Alternately, you can do:
$ ./a.out < textinput > results
The results will be printed in a file called, results
Use the unix program wc to verify the correctness of your program.
Write a program that reads numbers in one by one, and then add them up. The numbers are read in as characters.
Your program must do the following:
Copy all your files (including source code and executables)
into a directory named YourID_P2. Run your program to make sure that it behaves as expected and then copy the whole directory
to the CS server powerpuff.cs.brynmawr.edu. Submit the directory using the following command:
$ submit -c 246 -p 2 -d YourDirectory