This exam is closed book, closed notes, closed classmates.
You have 75 minutes to complete it.
Please put all answers on the test sheets. Make sure your answer is
clearly marked and easily distinguished from work you do to get to the
solution. You should show your work for partial credit.
When done, please staple together your exams sheets and any paper you
use for work and place it face down on the lecture table.
Please please print your name clearly below, and sign when you hand in
the exam, signifying your adherence to the honor code and attesting to
the work being yours alone.
Name (print) ---------------------------------------------------------------- Signed ---------------------------------------------------------------------
(a) < br/ > (b) < h2 > (c) < body > (d) < script >
(a) in the head section (b) between the head section and the body section (c) right after the < h1 > header in the body section (d) at the end of the body section answer: _______________
(a) parameters are passed to a function in the increasing
order of their importance to the algorithm
(b) when two function calls appear in one expression
( like abs(x)+round(y) ) they are called in alphabetic order
according to their names
(c) parameters are passed to a function by evaluating each
expression in the call and sending in the resulting values
(d) variable names must be chosen so that they have descriptive
value to people reading the program
answer: _______________
(a) fetch and execute cycle (b) CPU (c) byte
(1) (2) (3) (4) (5) (6)
answer: ________________
answer: ________________
var max = 6;
var num = 0;
var k = 0; // loop index
while (k < max) {
num = num + k;
k = k + 1;
}
alert(num);
answer: ________________
function doesSomething () {
var num = 16;
var res = 5;
res = cruncher(num);
alert("num: " + num + ", res: " + res);
}
function cruncher (aParm) {
aParm = aParm * 2;
return aParm;
}
answer: ________________
var x = 5;
var f = 5;
if (x < 10 ) { x = x + 1; }
else if (x == 5) { x = x - 2 ; }
else if (x > 0) { x = x * 3; }
else { x = -8 ; }
if (f < 10 ) { f = f + 1; }
if (f == 5) { f = f - 2 ; }
if (f > 0) { f = f * 3; }
else { f = -8 ; }
alert("x: " + x + ", f: " + f);
answer: ________________
var i; // loop index
var flag = true;
for (i=0; i<5; i++) {
flag = !flag ;
}
alert(flag);
answer: ________________
function exam1 ( ) {
var max = 100;
var arr = new Array(max);
var sLoc = -1;
getData(arr); // assume this function loads the array with data somehow;
// you do not need to write this function
sLoc = findSmallest(arr,max);
alert("smallest value is here: "+sLoc);
}
// write your function findSmallest to go here