Some people had difficulty realizing that both for loops with cout statements printed out 5 elements. ALSO, the values of the elements in the second output line were computed from the recently revised elements, not from the original elements!
Prob 2:
The first component of the class should be a character array of length 41 (not merely 40) in order to allow for 40 characters and a null character. The other components are not arrays. Each must end with a semi-colon.
The class must have a public attribute for every component or else certain sections cannot be accessed.
Prob 3:
A few people interchanged the "qualities" for variable and value parameters. (Note: a variable parameter is one that needs the & in the function header.)
Prob 4:
The ONLY difference between a class and a struct in C++ is the default attribute of public/private. In either feature (in C++) one can use member functions and explicitly change the default attribute.
Prob 5:
There should only be 4 output values.
Prob 6:
To "find" the maximum in an array is to determine which of the given values is the greatest (given the context here). This is not a "search" routine as is linear or binary. Thus you are supposed to check each value against what you thought the maximum value was, to increase it if needed, i.e., if the new iscore[i] is greater than the current max value.
Prob 7:
Some people tried to describe constructors and destructors in terms of functions. They only apply to classes (and structures) and normally are used to initialize (clean-up) internal class variables. They are automatically "called" when a variable of that class comes into existence and goes out of existence. Some people did not note what the name should be.
Prob 8:
There should be 5 output answers, the first of which should be 2 since it is initially pushed onto the stack and then immediately popped off and printed out.
Prob 9:
There seemed to be some confusion between the subscript and the (possible) value contain in the array element. Some people attempted to sum the values in the arrays and/or print out the values, rather than the subscripts. The subscripts are integer values and should never have fractional values.
Also, when the return statement is executed, either in the main program or in a function, the code ends and returns to the calling program (or the program merely stops). The return does not force the loop to end early and the program to continue after the loop with the other cout statement.
Finally, the last cout statement is OUTSIDE the loop, and in this case, is never executed.
Raw Normalized 99 74 97 71 97 71 95 69 93 66 91 64 89 61 89 61 87 59 87 59 86 58 86 58 83 54 80 50 79 49 74 43 73 42 72 40 72 40 70 38 69 37 69 37 67 34 67 34 66 33 39 10
x
x
x x x
x x x x
x x x x
x x x x
x x x x
x x x x x
30 40 50 60 70 80 90
(1 0 0 5 6 8 6)
This page is maintained by Dennis C. Smolarski, S.J.
dsmolarski@math.scu.edu
© Copyright 2001 Dennis C. Smolarski, SJ, All rights reserved.
Last changed: 3 November 2001.