Binary file coursework/cw02.pdf has changed
--- a/coursework/cw02.tex Sun Nov 10 09:27:01 2013 +0000
+++ b/coursework/cw02.tex Mon Nov 11 00:34:14 2013 +0000
@@ -133,10 +133,30 @@
\subsection*{Question 3 (marked with 1\%)}
Write a program in the WHILE programming language that prints out all prime numbers between
-0 and a fixed number (say 100). Take the grammar of this language from the lectures. As another
-guidance have a look at the Fibonacci program
-and ``three-nested-loops'' program shown below. For example, printing a variable \texttt{x} in the
-WHILE language can be done by using the command \mbox{\texttt{write x}}.
+0 and a fixed number (say 100). A partial grammar of the WHILE language is given below.
+
+\begin{center}
+\begin{tabular}{@{}lcl@{}}
+\textit{Stmt} & $\rightarrow$ & $\texttt{skip}$\\
+ & $|$ & \textit{Id}\;\texttt{:=}\;\textit{AExp}\\
+ & $|$ & \texttt{if}\; \textit{BExp} \;\texttt{then}\; \textit{Block} \;\texttt{else}\; \textit{Block}\\
+ & $|$ & \texttt{while}\; \textit{BExp} \;\texttt{do}\; \textit{Block}\\
+ & $|$ & \texttt{read}\;\textit{Id}\\
+ & $|$ & \texttt{write}\;\textit{Id}\\
+ & $|$ & \texttt{write}\;\textit{String}\medskip\\
+\textit{Stmts} & $\rightarrow$ & \textit{Stmt} \;\texttt{;}\; \textit{Stmts}\\
+ & $|$ & \textit{Stmt}\medskip\\
+\textit{Block} & $\rightarrow$ & \texttt{\{}\,\textit{Stmts}\,\texttt{\}}\\
+ & $|$ & \textit{Stmt}\medskip\\
+\textit{AExp} & $\rightarrow$ & \ldots\\
+\textit{BExp} & $\rightarrow$ & \ldots\\
+\end{tabular}
+\end{center}
+
+\noindent
+As another guidance for your program have a look at the Fibonacci program
+and ``three-nested-loops'' program shown below in Figures \ref{fib} and \ref{loop}.
+
\begin{figure}[h]
\begin{center}
--- a/progs/fib.while Sun Nov 10 09:27:01 2013 +0000
+++ b/progs/fib.while Mon Nov 11 00:34:14 2013 +0000
@@ -1,4 +1,4 @@
-/* Fibonnacci sequence implemented in
+/* Fibonnacci numbers implemented in
the WHILE language */
write "Input a number ";
--- a/progs/loops.while Sun Nov 10 09:27:01 2013 +0000
+++ b/progs/loops.while Mon Nov 11 00:34:14 2013 +0000
@@ -1,4 +1,4 @@
-start := 1000;
+start := 1000; // start value
x := start;
y := start;
z := start;