CS 2213 Advanced Programming, Fall 2000 Exam 1 Comments
The solutions were handed out in class.
Grade Distribution:
| Range | Number |
| 90's | 5 |
| 80's | 14 |
| 70's | 11 |
| 60's | 19 |
| 50's | 8 |
| 40's | 5 |
| 30's | 5 |
- Problem 2
- a) The first indicates a function with no parameters and the
second indicates a function whose parameters are unspecified.
- b) *x++ is the same as *(x++);
- d) labels have function scope so you can only jump to a label
within the current function.
- g) Only variables with static storage class are initialized by default.
- Problem 3
Pointers take up 4 bytes, independent of what they are pointing to.
For part h) the newline and the terminator each take up one byte.
- Problem 4
- The function should return void.
- If you write it to return a value, then you must have an
appropriate return statement.
- Problem 5
- In C, a string is an array of characters terminated by the string
terminator character.
- The string terminator is '\0', not '\n'.
- Since no return value was specified, this function would return
void.
- You can determine the length of a string by looking for the
terminator.
- The first parameter should be the destination and the second
parameter should be the source.
- Problem 6
- In a heap, the parent and child may have the same value.
- It is much easier to check the parent of each node, rather than
the children of each node. Each node other than the root has
a unique parent. Some nodes have no children, some may have
one and some may have two. It is wrong to access the child of
a node that does not have a child.
- Try to make your programs simple to follow.
- Do not print anything.
- Problem 7
- A filter is a main program, not just a function.
- You should look for an EOF not an end of line or string terminator.
- " " is a string containing a single blank and takes
up 2 bytes of storage.
This is different from ' ' which is a character which
takes up one byte of storage.
- In this problem a tab is an ordinary character. Only blanks are
special.
- You need to assign the result of getchar to an integer
if you are going to check for end of file.
- When writing program it is best to write one statement per line.
- This program should not print anything.