Binary file cws/cw02.pdf has changed
--- a/cws/cw02.tex Sat Dec 04 00:41:31 2021 +0000
+++ b/cws/cw02.tex Sat Dec 04 00:49:34 2021 +0000
@@ -193,18 +193,18 @@
\begin{figure}[h]
-\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/while-tests/fib.while}}
+\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../cwtests/cw02/fib.while}}
\caption{Fibonacci program in the WHILE language.\label{fib}}
\end{figure}
\begin{figure}[h]
-\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/while-tests/loops.while}}
+\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../cwtests/cw02/loops.while}}
\caption{The three-nested-loops program in the WHILE language.
(Usually used for timing measurements.)\label{loop}}
\end{figure}
\begin{figure}[h]
-\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../progs/while-tests/factors.while}}
+\mbox{\lstinputlisting[language=While,xleftmargin=10mm]{../cwtests/cw02/factors.while}}
\caption{A program that calculates factors for numbers in the WHILE
language.\label{factors}}
\end{figure}
Binary file cws/cw03.pdf has changed
--- a/cws/cw03.tex Sat Dec 04 00:41:31 2021 +0000
+++ b/cws/cw03.tex Sat Dec 04 00:49:34 2021 +0000
@@ -138,24 +138,24 @@
1 Minute?
\begin{figure}[h]
-\lstinputlisting[language=while,xleftmargin=20mm]{../progs/while-tests/fib.while}
+\lstinputlisting[language=while,xleftmargin=20mm]{../cwtests/cw03/fib.while}
\caption{Fibonacci program in the WHILE language.\label{fib}}
\end{figure}
\begin{figure}[h]
-\lstinputlisting[language=while,xleftmargin=20mm]{../progs/while-tests/loops.while}
+\lstinputlisting[language=while,xleftmargin=20mm]{../cwtests/cw03/loops.while}
\caption{The three-nested-loops program in the WHILE language.
Usually used for timing measurements.\label{loop}}
\end{figure}
\begin{figure}[h]
-\lstinputlisting[language=while,xleftmargin=0mm]{../progs/while-tests/primes.while}
+\lstinputlisting[language=while,xleftmargin=0mm]{../cwtests/cw03/primes.while}
\caption{Prime number program.\label{primes}}
\end{figure}
\begin{figure}[p]
-\lstinputlisting[language=while,xleftmargin=0mm]{../progs/while-tests/collatz2.while}
+\lstinputlisting[language=while,xleftmargin=0mm]{../cwtests/cw03/collatz2.while}
\caption{Collatz series program.\label{collatz}}
\end{figure}
--- a/cwtests/cw02/factors.while Sat Dec 04 00:41:31 2021 +0000
+++ b/cwtests/cw02/factors.while Sat Dec 04 00:49:34 2021 +0000
@@ -1,11 +1,13 @@
// Find all factors of a given input number
-write "Input n please";
+write "Input n please: ";
read n;
-write "\nThe factors of n are";
+write "The factors of n are: \n";
f := 2;
while (f < n / 2 + 1) do {
- if ((n / f) * f == n) then { write(f); write("\n") } else { skip };
+ if ((n / f) * f == n)
+ then { write(f); write("\n") }
+ else { skip };
f := f + 1
}
\ No newline at end of file