August
1997 QUESTION 4 Total Marks: 20 Marks |
Click here to access other
questions
Click to access |
| 4. | (a) What are the values I and J in the following program segment? | [2] | |
|
|||
| (b) What does the following program print? | [4] | ||
|
|||
| (c) Define implementations of the following library functions: | |||
| int strlen (char *str); | |||
| void strncpy (char *dst, char *src, int n); | |||
| void strrev (char *dst, char *src); |
|||
| (i) Where strlen, returns the number of characters in the string stc. | [4] | ||
| (ii) Where strncpy, copies at most n characters of the string stc into dst. You can assume that dst is a character string with at least n elements. | [5] | ||
| (iii) Where strrev, copies a reversed version of src into dst. Note: you may use strlen in your definition. | [5] | ||