Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Modern computers include a memory hierarchy that include both larger quantiti

ID: 638468 • Letter: 1

Question

1. Modern computers include a memory hierarchy that include both larger quantities of slower
memory and smaller quantities of faster memory. Which of the following accurately describes
the relationship of main memory, secondary storage, and registers in a modern computer?
(a) main memory is faster than secondary storage which is faster than registers
(b) secondary storage is faster than main memory which is faster than registers
(c) registers are faster than main memory which is faster than secondary storage
(d) main memory is faster than registers which are faster than secondary storage
(e) secondary storage is faster than registers which are faster than main memory

31. #include "defs.h"
32.
33. void removePunctuation(char *s)
34. {
35. int i;
36. int j;
37. for(i = 0; i < strlen(s); i++) {
38. if( isPunctuation(s[i]) ) {
39. for(j = i + 1; j <= strlen(s); j++)
40. s[j-1] = s[j];
41. i--;
42. } }
43. }
44.
45. int isPunctuation(char c)
46. {
47. if( c >=

Explanation / Answer

Answers:

1) (c) registers are faster than main memory which is faster than secondary storage

2) (d) Actually, it IS a real problem. This program only works for input that includes no
spaces.

3) (b) If we tested i to strlen we would always see the string terminator (’’) as punctuation and get rid of it, thereby making the string, s, unterminated. By testing j to
strlen(s), in contrast, we make sure that the string terminator is moved down, as it
should be to since the punctuation removed makes s one character shorter than it used
to be.

4) (d) Strcmp takes two strings as parameters and returns a positive value (more than 0) if
the first parameter string is “alphabetically” greater than the second parameter string,
a negative value (less than 0) if the first parameter string is “alphabetically” less than
second parameter string, and 0 if the two strings are same.