Documentos de Académico
Documentos de Profesional
Documentos de Cultura
3' Given the vector v declared below, the following cout statement will always
cause a runtime error.
vector(int> v(9,1);
cout << vl9l << endl;
A. TRUE b. FALSE
4' Given the vector v declared in the previous question, the following cout statement
will always
cause a runtime error.
cout (( v. at ( 9 ) (( endl ,.
a. TRUE b. FALSE
L.1b.2c.4d.5e.Gf.g
8. What would be output by the following code fragement?
Page I of4
10. Which of the following expressions will always be true if a vector v stores at least 1 value?
a- v.sizeO :: 1 c. v-emPtYo
b' v.at(O) >: 0 d. lv.ern,t'o
11. Given the following declaration of the struct Time and a variable t of type Time, which statement
has a syntax error (assume the 4 statements are within the main function)?
struct Time {
int hour;
int minute;
t;
int main0 {
Time t;
)
a. cout << t.hour << endf;
b. t.hour : 10;
C. t.minute : 30;
d. cout (( t << endl-;
{2. Given the following declaration of the class Point and a variable p of type Point which statement
has a syntax error (assume the 4 statements are within the main function)?
cl-ass Point {
private:
doubfe xcoord;
double ycoord;
public:
Point ( ) ;
Point (doubl-e, doub]e) ;
doubl-e getXO const;
doub]e getYO const;
void move (doub]e, double) ;
);
int maino {
Point p;
)
A. doub1ex:p.xcoord;
b. Point p2 : Point (1.4 , 2.0);
c. p.move (1.5, 2-4);
d. cout (( p.qetXO << endl-;
PageZ of 4
Nurr"iri{!-:'':.:,''J.' rt''''-ii:':" Login
13. (5 points) Write the definition for the function f ind declared below?
Page 3 of4
UrCd le L Pe
snah
14. (5 points) Write a function named cof_averages that passes ina2d(two-dimensional) array
of ints with NROWS number of rows and NCOLS number of columns (assume NROWS and
NCOLS are global constants) andasingle-dimensional array of doubles of size NCOLS. The
-void.' the ld array with the column averages. The function should have a return Epe of
. _fUgcIgo{lls
(/
'
\.-*--"" _--
For example, if the 2dxray had the values:
1t_221L2
2223222
3318432
1111111
2222222
then the function should populate the ld array with the following averages:
Recall, you can convert an expression exp's type from int to double like this:
s tatic_cast.(double> ( exp )
t ,/,
\
\,ie"
v- Q
-ol
yw6iu *rr I
t a
r:rtl,*CIMeY<lqPS -(
g
L =$(*rsr)
iIucbtg ,{ {t}
{or ( urrt*$nrcJ ifit'J-- }
lnt s L4rll *'ei l qIOUU t* {i{b( t {4 qt t
tf {rr luet ag e ,
}.y$ \-=
3 '/ -c:(
,3
Page 4 of4