Assignment 1

Due by 6pm on Sunday, January 17.
Create a file named hw.c in your math211hw directory. This file should be a copy of the "Hello world" program and should print
Hello world.
on the screen and the prompt should appear on the next line. If you want to make sure that I will be able to collect your file, type
Assign1
and hit return. You should get a message back telling you that your file was found.
Here is a correct version of the assignment.

Assignment 2

Due by midnight on Friday, January 22.
Create a file cf.c in your math211hw directory. This file should contain a program which, when it is run, produces a list of temperatures. The first entry on each row should be a Celcius temperature, followed by a tab, followed by the corresponding Fahrenheit temperature, followed by a new line. The first Celcius temperature should be -50 degrees and the last should be 50 degrees. The difference between consecutive temperatures should be 2.5 degrees Celcius. Both the Celcius and Fahrenheit temperatures should be decimals, at least six characters wide with one character after the decimal point.

If you want to make sure that I will be able to collect your file, type
Assign2
and hit return. You should get a message back telling you that your file was found.
Here is a correct version of the assignment .


Assignment 3

Due by midnight on Sunday, January 31. Resubmit by 8am Tuesday February 2.
Create a file hcount.c in your math211hw directory. This file is to contain a program which counts all the words from standard input which start with the letter "a" or "A" and which are at least 3 characters long. The definition of a word is the same as we have used in class - any string of characters which are not spaces, tabs, newlines or EOF. Print out the count as a base 10 integer using at least 6 spaces and then print a newline so the prompt is on the next line.

If you want to make sure that I will be able to collect your file, type
Assign3
and hit return. You should get a message back telling you that your file was found.
Here is a correct version of the assignment.


Assignment 4

Due by midnight on Thursday, February 25. Modify your copies of Calc.c, Stack.c and Stack.h so that you get the following behavior. Typing a lower case c clears the stack and typing a lower case e clears the current number entry from the stack. You need to add one (and only one) function to the Stack files: it is to be called clear and it takes no variables and returns a void. [Added: a call to the function clear() is to clear the stack.] You also need to make two (and only two) modifications in the code for main.

If you need fresh copies of any of these three files type copy_file and then the names of the files you want. First make sure that your homework directory has no files by the same name. As an example
copy_file Stack.c Calc.c
will put new copies of Calc.c and Stack.c into your homework directory but it will leave Stack.h untouched. As of 12:30 on 02/24 I hope "copy_file" is up and working. If you need copies of Calc.c, Stack.c or Stack.h just type
copy_file Calc.c
and hit return.

If you do "copy_file a4.prog" you should get a file in your math211hw directory which is a working version of your homework assignment. It also has the 's' from this morning working properly. You can use this program to see what ought to happen with a working version of your assignemnt.

If you want to make sure that I will be able to collect your file, type
Assign4
and hit return. You should get a message back telling you that the assignment was found.


Assignment 5

Due by midnight on Wednesday, March 3. Modify your copies of Calc.c, Stack.c and Stack.h so that you get the following behavior. Typing a lower case p prints the stack: on the first line it prints [0], then a tab, then the value of the first element on the stack, then a newline; then it prints a [1], then a tab, then the value of the second element on the stack; and so on until all the entries on the stack have been printed: if there are no entries on the stack it should print a single line consisting of "The stack is currently empty." followed by a newline. You need to add one (and only one) function to the Stack files: it is to be called print_stack and it takes no variables and returns a void. After print_stack is finished, the stack should be in the same condition in which you found it. You also need to make only one modification in the code for main. You should have 3 files in your math211hw directory: Calc.c, Stack.c and Stack.h. "cc Calc.c Stack.c" should compile a working version of your program.

You should fix your clear function if needed and make sure 'e' and 'c' work as in Assignment 4.
"copy_file a5.prog" will get you a working copy of the program.
"lsdot" will get you a list of the files you can copy if you want.
If you type Assign4 you should get a message back telling you if I can or cannot find your homework (NOTE Assign4 NOT Assign5!).


Assignment 6

Due by midnight on Friday, April 9, 1999. This assignment has one file, called bettergetword.c Inside you need to write two functions, get1wordA and get1wordB.
Both of them have the same declaration as get1word and you can use a good deal of the code as well.
The function get1wordA is to return the length of the word, or -1 if the file has terminated. The only difference between this and the function get1word is that we want strings like "don't" and "non-void" to be words instead of splitting into two words as they do now. You should be able to do this by just replacing the library function isalpha by a function of your own which recognizes ' and - as valid word characters.
The function get1wordB does the same thing as get1wordA except that it requires that a word actually contain at least one alphabetical character. For instance, get1wordA when handed -3 returns -, get1wordB should just skip the whole thing.
get1wordA should be fairly easy for you: get1wordB is a bit harder.

Assignment 7

Due by midnight on Sunday, April 18, 1999. Create a single file called get1word.c. Inside this file should be one function, get1word, with the usual declaration: int get1word(char*,short);. This function collects a word from the input stream in the array pointed to by the char pointer (with the short indicating how much room is available) and makes sure the word is stored as a C-string. The function returns either the length or -1 if the EOF is reached. The only substantive change from the last assignment is in the definition of a word. This time I want the word to start with an alphabetical character and thereafter have either alphabetical characters, or '\''s or '-'s. This can be done by adjusting one line of a working get1wordA from assignment 6. On Thursday at midnight I will do a preliminary collection and on Friday morning you will get an email with either a perfect or a 0. If you have a perfect on Thursday night you will have a perfect on Sunday night, but otherwise you might want to do further work on Friday, Saturday and/or Sunday.

Assignment 8

Write a new get1word with the declaration
int get1word(char* cptr, short wl, FILE *ff);
It should return the same kind of words as before, except, for use with web-pages, it should have the following additional behavior. When it encounters the character '<' it should then skip all the characters in the input stream until it finds a '>' character, at which point it should return to its more usual behavior. I would base a solution on my current get1word: the issues to deal with are to figure out where this routine encounters '<''s and then how to skip to the next '>'. To do this you will need to study (and use) the function ungetc described on page 247.
Usual stuff: due Monday, April 26 at midnight. File in math211hw directory to be called get1wordA.c: function to be called get1word. You may write other functions that you need for your get1word, but this file will be compiled with others and so should not contain main or any other functions that you are not actually going to use.
There is a file wa8 available for copying that will give you a working version of the program using the new get1word.

Back.