Exam 2 Review Quiz 09

Parameters i aanarrayofintegers ii

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: its size */ int FindMin(int array, int size) { int min = 0; for (int i=0; i <= size; i++) { if (i < min) { min = array[i]; } } } (b) Assume
that
the
2D
array

 int x[100][5] has
already
been
declared
and
defined. 
 /* Prints out all the elements of the 2D array X */ for (int i=0; i<=5; i++) { cout X[i][j]; } 
 
 
 
 
 
 
 
 
 
 
 
 (c) 
 /* Function sets every element of the array arr to init_value. Size = size of the array. */ int InitArray(int arr, int init_value, int size) { for (int i=0; i<= size; i+1) { cout << init_value; } } 
 
 Problem
3:
25
points.
 
 Write
short
snippets
of
code
to
accomplish
the
following
tasks:
 
 (a) For
an
array
that
has
been
declared
as
 
 float floatArr[5][8]; 
 write
asnippet
of
code
that
computes
and
prints
the
average
of
all
the
 elements
in
the
entire
array.
 
 
 
 
 
 
 
 
 
 
 
 (b) Write
a
snippet
of
code
that
repeatedly
asks
for
the
user’s
input
as
a
 character.

If
the
user’s
input
is
‘u’,
your
code
should
call
the
function
 Update(),
which
has
no
inputs.

If
the
user’s
input
is
‘p’,
your
code
should
 call
the
function
Print(),
which
has
no
inputs.

If
th...
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