Midterm 2 Review Quiz 09

Problem325points

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r (int i = 1; i <= 3; i++) { for (int j = 1; j <= 2; j++) { cout << i+j << " "; } cout << endl; }
 (b) 
 int a[6] = {5, 8, 7, 9, 13, -1}; cout << a[4] << endl; (c) If
the
following
function
is
defined
somewhere
in
the
program
and
 prototyped
above
main….
 
 int square(int& x) { return x*x; } 
 …what
does
the
following
code
print?
 
 int x = 5; int y = square(x); cout << x << endl; cout << y << endl; Problem
2:
10
points.
 
 
 (a) For
the
snippet
of
code…
 
 float f[50];
 
 …what
is
the
datatype
of
f[15]?
 
 
 
 
 
 
 
 
 (b) Assume
that
the
following
declaration
appears
above
the
main
program:
 
 struct team_record { string team_name; float total_score; float num_wins; }; 
 For
the
snippet
of
code…
 
 team_record teams[2];...
View Full Document

This note was uploaded on 02/08/2014 for the course CS 115 taught by Professor Staff during the Fall '08 term at Sonoma.

Ask a homework question - tutors are online