cmp217 Image Map
Assignments
Revised:
Assignment
Number
Assignment Date Due Points
1 Write a C Program that prints an ASCII table for the characters valued 32 to 127. The character along with its integer value should be printed in decimal octal and hex. 2/10 20
Top of Page
2 Implement the CGI library (mycgilib.c) covered in class on 2/9. The source files (.c and .h )are to be in a subdirectory (folder) of you home directory CGI. 2/16 20
Top of Page
3 Use the CGI library (mycgilib.c) to write a Farenheight to Celcius cgi program. The program should produce output in two columns with headers for the columns. 2/18 20
Top of Page
Info See some notes on CGI and preprocessor in cginotes.htm 2/18 20
Top of Page
4 Write the Lotto program as covered and discussed in class.

The program must have the following functions:

  • int unique(int list[], int nele, int cand)
    returns 1 if the cand is not is the list of nele.
  • int pick(int mn)
    returns a random nuber r such that 1 <= r <= mn,
  • void printnums(int list[], int nele)
    prints the list of nele entries.
The program must work as a CGI and as a non-server application.
3/11 40
Top of Page
5 Write a procedure called:
void sort(int list[], int size)
that sorts an array of integers via the Selection Sort algorithm. The Selection sort is as follows:
while the size of the list is greater than 1
   find the largest element in the list
   swap that element with the last element in the list
   decrease the size of the list by 1
The function must make use of a function you wrote in assignment 6.

The following program is to be used as the main program and submitted with the assignment

#include <stdio.h>
main()
{
   int numbers[] = {3,4,0,1,15,6,4,35,14,7,42,2};
   int listsize;
listsize= ( sizeof numbers )/ sizeof(numbers[0]);
printf("The original list is: ");
printnums(numbers,listsize);
sort(numbers,listsize);
printf("The sorted list is: ");
printnums(numbers,listsize);
return 0;
}
3/11 20
Top of Page
6 Implement the sort() routine into the lotto program. 3/11 20
Top of Page
Top of Page final part 1
  1. Write a function int countdelim(char *buf, char c) that counts the number of times a delimiter appears in the buffer buf. The program must use function must use pointers and pointer arithematic.
  2. Write a function int countdelim(char buf[], char c) that counts the number of times a delimiter appears in the buffer buf. The program must use function must use arrays.
  3. Write a function called int parseit(char *words[], int nwords, char *buf, char delimiter) that replaces the delimiter in buf with a NULL and sets the elements of words to be the starting address of the delimitted words. Assume a maximum of nwords. The function returns the actual number of words.
5/18 20 Top of Page