The errors from the first program:

Code:
E-8-1-8a.cpp:21: error: `vals' undeclared (first use this function)
E-8-1-8a.cpp:21: error: (Each undeclared identifier is reported only once for 
   each function it appears in.)
E-8-1-8a.cpp:23: error: `numels' undeclared (first use this function)
E-8-1-8a.cpp:27:2: warning: no newline at end of file
E-8-1-8a.cpp:27: error: syntax error at end of input