<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/technology/cnxml/schema/dtd/0.5/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" xmlns:m="http://www.w3.org/1998/Math/MathML" id="new">
  <name>Programming in LabVIEW MathScript-Simple While Loop Exercises</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2006/08/02 12:37:37.031 GMT-5</md:created>
  <md:revised>2006/08/03 00:50:15.903 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="aantonac">
      <md:firstname>Anthony</md:firstname>
      <md:othername>Gene</md:othername>
      <md:surname>Antonacci</md:surname>
      <md:email>aantonac@utk.edu</md:email>
    </md:author>
      <md:author id="morrell">
      <md:firstname>Darryl </md:firstname>
      
      <md:surname>Morrell</md:surname>
      <md:email>morrell@asu.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="aantonac">
      <md:firstname>Anthony</md:firstname>
      <md:othername>Gene</md:othername>
      <md:surname>Antonacci</md:surname>
      <md:email>aantonac@utk.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>Exercises</md:keyword>
    <md:keyword>LabVIEW</md:keyword>
    <md:keyword>MathScript</md:keyword>
    <md:keyword>While Loop</md:keyword>
  </md:keywordlist>

  <md:abstract>This module provides several simple exercises designed to test and increase your understanding of while loops in LabVIEW MathScript.</md:abstract>
</metadata>
<content>

  <section id="SecReview">
    <name>Some While Loop Exercises</name>

    <exercise id="ExAa">
      <problem id="ProbAa">
        <para id="ParaAa">
          How many times will this loop print 'Hello World'?
          <code type="block">
n = 10;
while n &gt; 0
    disp('Hello World')
    n = n - 1;
end
</code>
        </para>
      </problem>
      <solution>
        <para id="SolAa">10 times.
        </para>
      </solution>
    </exercise>

    <exercise id="Ex2">
      <problem id="Prob2">
        <para id="Par2">
          How many times will this loop print 'Hello World'?
          <code type="block">
n = 1;
while n &gt; 0
    disp('Hello World')
    n = n + 1;
end
</code>
        </para>
      </problem>
      <solution>
        <para id="Sol2a">This loop will continue to print 'Hello World' until the user stops the program.  You can stop a program by holding down the 'Ctrl' key and simultaneously pressing the 'c' key.
        </para>
      </solution>
    </exercise>

    <exercise id="Ex3">
      <problem id="Prob3">
        <para id="Par3">
          What values will the following LABVIEW MATHSCRIPT code print?
          <code type="block">a = 1
while a &lt; 100
    a = a*2
end
</code>
        </para>
      </problem>
      <solution>
        <para id="Sol3a"><code type="block">a =
     1
a =
     2
a =
     4
a =
     8
a =
    16
a =
    32
a =
    64
a =
   128</code>
        </para>
      </solution>
    </exercise>

    <exercise id="Ex4">
      <problem id="Prob4">
        <para id="Par4">
          What values will the following LABVIEW MATHSCRIPT code print?
          <code type="block">
a = 1;
n = 1;
while a &lt; 100
    a = a*n
    n = n + 1;
end
</code>
        </para>
      </problem>
      <solution>
        <para id="Sol4a"><code type="block">
a =
     1
a =
     2
a =
     6
a =
    24
a =
   120
</code>     </para>
      </solution>
    </exercise>

  </section> 
</content>
  
</document>
