Assignment 3

Due 10/28/2004

 

Assignment 3 consists of a number of small programs, each a minor modification of the sample programs found in Section 1.5 of [K&R]. Some of the programs are somewhat non-trivial. Try to get as many right as you can. You may ask for help, but you should not copy other students’ program as your own. Do not cheat.

 

The following is the list of problems. The order does not necessarily imply level of difficulty:

 

3.1.        Write a program to count the number of times the letter ‘a’ appears in the standard input. Print out the number at the end of the program.

3.2.        Write a program to copy the standard input to the standard output while replacing each occurrence of the letter ‘a’ with the letter ‘A’.

3.3.        Write a program to copy the standard input to the standard output while replacing the first occurrence of the letter ‘a’ in each line with the letter ‘A’.

3.4.        Write a program to copy the standard input to the standard output while changing each lower case letter (‘a’-‘z’) to upper case (‘A’-‘Z’).

3.5.        Write a program to print a line count, a word count, and a character count for each line of input. The newline character counts as one character.

3.6.        Write a program to copy the standard input to the standard output while removing characters from column 6 to column 11.

3.7.        Write a program to count the number of times the string “//” appears in the standard input. Print out the number at the end of the program. Count only disjoint strings, i.e., “////” counts as two occurrences, not three.

 

How to turn in your assignment

Copy this file to your PC and replace the printf( ) statements with your code. Email this file with your ID and name to c04@freefall.csie.isu.edu.tw. The deadline is midnight, Oct. 28, 2004. Once again, you may get help from others, but you should not copy other students’ program as your own. Do not cheat.