<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE quiz SYSTEM "ttxml.dtd">

<quiz>

<text><p>CISC105/106 honors, E01, Multiple Choice (10/05/2007)</p></text>


<enterSeed />

<shuffle>
  <question>
  <text>
    <p>(5 pts) Suppose you have the following M file in your current working directory.</p>
<pre><![CDATA[
function result = mysteryFunction(a,b)
%mysteryFunction does something mysterious
%Examples:
%  ... (omitted to make you think harder)
%D. Duck for CISC106 sect 99, 11/10/2006
  if (a < b)
    result = b / a;
  else
    result = a / b;
  return;
end;
]]></pre>
<p>Then suppose you type the following at the MATLAB prompt.</p>

<pre><![CDATA[
>> mysteryFunction(3,6)
]]></pre>

<p>What is the output?</p>

  </text>
  <multipleChoice>

<choice answer="true">
<pre><![CDATA[
ans = 
      2
>>
]]></pre></choice>

<choice><pre><![CDATA[
ans = 
      3
>> 
]]></pre></choice>

<choice>No output, just a new <code>&gt;&gt;</code> prompt. </choice>

<choice><pre><![CDATA[
ans =
      0.5
>>
]]></pre></choice>

<choice><pre><![CDATA[
ans =
      3   6
>>
]]></pre></choice>
	
  </multipleChoice>
  </question>


  <question>
  <text>
    <p>(5 pts) Suppose you have the following M file in your current working directory.</p>
<pre><![CDATA[
function result = yetAnotherFunction(a,b)
%yetAnotherFunction does something with a and b
%Examples:
%  ... (omitted to make you think harder)
%D. Duck for CISC106 sect 99, 11/10/2006
  if (a < b)
    result = [ a b ];
  else
    result = [ b a ];
  end
  return;
end
]]></pre>
<p>Then suppose you type the following at the MATLAB prompt.</p>

<pre><![CDATA[
>> yetAnotherFunction(6,3)
]]></pre>

<p>What is the output?</p>

  </text>
  <multipleChoice>

<choice answer="true">
<pre><![CDATA[
ans = 
      3   6
>>
]]></pre></choice>

<choice><pre><![CDATA[
ans = 
       18
>> 
]]></pre></choice>

<choice>No output, just a new <code>&gt;&gt;</code> prompt. </choice>

<choice><pre><![CDATA[
ans =
      6   3
>>
]]></pre></choice>

<choice><pre><![CDATA[
ans =
      2
>>
]]></pre></choice>
	
  </multipleChoice>
  </question>



  <question>
  <text>
    <p>(5 pts) Suppose you have the following M file in your current working directory.</p>
<pre><![CDATA[

function result = stillOneMoreFunction(v)
%stillOneMoreFunction does something with a vector v
%Examples:
%  ... (omitted to make you think harder)
%D. Duck for CISC106 sect 99, 11/10/2006
  result = 1;
  for k=1:length(v)
     result = result * v(k);
  end
  return
end

]]></pre>
<p>Then suppose you type the following at the MATLAB prompt.</p>

<pre><![CDATA[
>> stillOneMoreFunction([3 4])
]]></pre>

<p>What is the output?</p>

  </text>
  <multipleChoice>

<choice answer="true">
<pre><![CDATA[
ans = 
      12
>>
]]></pre></choice>

<choice><pre><![CDATA[
ans = 
       4   3
>> 
]]></pre></choice>

<choice>No output, just a new <code>&gt;&gt;</code> prompt. </choice>

<choice><pre><![CDATA[
ans =
       3   4
>>
]]></pre></choice>

<choice><pre><![CDATA[
ans =
      1  3   4
>>
]]></pre></choice>
	
  </multipleChoice>
  </question>

  <question>
  <text>
    <p>(5 pts) Suppose you execute the following MATLAB code.</p>
<pre><![CDATA[
x = 4;
y = x * 3;
if (y > x)
  disp(y);
else
  disp(x);
end
]]></pre>

<p>What is the output?</p>

  </text>
  <multipleChoice>

<choice answer="true"><code>12</code></choice>
<choice><code>3</code></choice>
<choice><code>4</code></choice>
<choice><code>x</code></choice>
<choice><code>y</code></choice>

  </multipleChoice>
  </question>

  <question>
  <text>
    <p>(5 pts) Suppose you execute the following MATLAB code.</p>
<pre><![CDATA[
x = 4;
y = x + 1;
if (y >= x)
  disp('y');
else
  disp('x');
end
]]></pre>

<p>What is the output?</p>

  </text>
  <multipleChoice>

<choice answer="true"><code>y</code></choice>
<choice><code>x</code></choice>
<choice><code>4</code></choice>
<choice><code>5</code></choice>
<choice><code>'y'</code></choice>

  </multipleChoice>
  </question>


  <question>
  <text>
    <p>(5 pts) Suppose you execute the following MATLAB code.</p>
<pre><![CDATA[
x = 5;
y = 7;
for i = x:y
  disp(i - x);
end
]]></pre>

<p>What is the output?</p>

  </text>
  <multipleChoice>

<choice answer="true"><pre><![CDATA[
0
1
2
]]></pre></choice>


<choice>
<pre><![CDATA[
i - x
i - x
i - x
]]></pre></choice>

<choice><pre><![CDATA[
5 6 7
]]></pre></choice>


<choice><pre><![CDATA[
5   7
]]></pre></choice>



<choice><pre><![CDATA[
0 1 2
]]></pre></choice>

  </multipleChoice>
  </question>



  <question>
  <text>
    <p>(5 pts) Suppose you execute the following MATLAB code.</p>
<pre><![CDATA[
v = [2 4 5];
sum = 0;
for i=1:length(v) 
  sum = sum + v;
end
disp(sum)
]]></pre>

<p>What is the output?</p>

  </text>
  <multipleChoice>

<choice answer="true">
<pre><![CDATA[
6 12 15
]]></pre></choice>

<choice><pre><![CDATA[
11
]]></pre></choice>


<choice><pre><![CDATA[
2  4  5
]]></pre></choice>


<choice><pre><![CDATA[
sum
]]></pre></choice>

<choice><pre><![CDATA[
5
]]></pre></choice>

  </multipleChoice>
  </question>



  <question>
  <text>
    <p>(5 pts) Suppose you execute the following MATLAB code.</p>
<pre><![CDATA[
v = [4 2 7];
sum = 0;
for i=1:length(v) 
  sum = sum + v(i);
end
disp(sum)
]]></pre>

<p>What is the output?</p>

  </text>
  <multipleChoice>

<choice answer="true">
<pre><![CDATA[
13
]]></pre></choice>

<choice><pre><![CDATA[
4 2 7
]]></pre></choice>


<choice><pre><![CDATA[
6
]]></pre></choice>


<choice><pre><![CDATA[
1 2 3
]]></pre></choice>

<choice><pre><![CDATA[
3
]]></pre></choice>

  </multipleChoice>
  </question>

</shuffle>


<text><p>End of E02 multiple choice</p></text>

</quiz>







