Skip to content

Commit af81233

Browse files
committed
updated third exercise, added handouts
1 parent 0b53ec3 commit af81233

7 files changed

+437
-3
lines changed

guessingGame.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
#include<stdio.h>
1+
/**
2+
* This program plays a guessing game with the user.
3+
* It selects a random number between 1 and 1000 and
4+
* prompts the user to guess the value, informing them
5+
* of whether or not it is higher or lower than the
6+
* actual value. Once the user guesses correctly, the
7+
* game ends and the number of guesses is displayed.
8+
*/
29
#include<stdlib.h>
10+
#include<stdio.h>
311

412
int main(int argc, char **argv) {
513

@@ -17,6 +25,6 @@ int main(int argc, char **argv) {
1725

1826
//TODO: place your code here
1927

20-
printf("Congratulations, you found it! Number of guesses: %d\n", num_guesses);
28+
printf("Congratulations, you found it! Number of guesses: %d\n", num_guesses);
2129
return 0;
2230
}

handouts/Lab-Loops-Worksheet.pdf

35.9 KB
Binary file not shown.

handouts/Lab-Loops-Worksheet.tex

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
\documentclass[12pt]{exam}
2+
3+
\usepackage{fullpage}
4+
5+
\setlength{\parindent}{0pt}
6+
\setlength{\parskip}{.25cm}
7+
8+
\usepackage{graphicx}
9+
10+
\usepackage{xcolor}
11+
12+
\definecolor{darkred}{rgb}{0.5,0,0}
13+
\definecolor{darkgreen}{rgb}{0,0.5,0}
14+
\usepackage{hyperref}
15+
\hypersetup{
16+
letterpaper,
17+
colorlinks,
18+
linkcolor=red,
19+
citecolor=darkgreen,
20+
menucolor=darkred,
21+
urlcolor=blue,
22+
pdfpagemode=none,
23+
pdftitle={Introduction To Git},
24+
pdfauthor={Christopher M. Bourke},
25+
pdfcreator={$ $Id: cv-us.tex,v 1.28 2009/01/01 00:00:00 cbourke Exp $ $},
26+
pdfsubject={PhD Thesis},
27+
pdfkeywords={}
28+
}
29+
30+
\definecolor{MyDarkBlue}{rgb}{0,0.08,0.45}
31+
\definecolor{MyDarkRed}{rgb}{0.45,0.08,0}
32+
\definecolor{MyDarkGreen}{rgb}{0.08,0.45,0.08}
33+
34+
\definecolor{mintedBackground}{rgb}{0.95,0.95,0.95}
35+
\definecolor{mintedInlineBackground}{rgb}{.90,.90,1}
36+
37+
%\usepackage{newfloat}
38+
\usepackage[newfloat=true]{minted}
39+
\setminted{mathescape,
40+
linenos,
41+
autogobble,
42+
frame=none,
43+
framesep=2mm,
44+
framerule=0.4pt,
45+
%label=foo,
46+
xleftmargin=2em,
47+
xrightmargin=0em,
48+
startinline=true, %PHP only, allow it to omit the PHP Tags *** with this option, variables using dollar sign in comments are treated as latex math
49+
numbersep=10pt, %gap between line numbers and start of line
50+
style=default, %syntax highlighting style, default is "default"
51+
%gallery: http://help.farbox.com/pygments.html
52+
%list available: pygmentize -L styles
53+
bgcolor=mintedBackground} %prevents breaking across pages
54+
55+
\setmintedinline{bgcolor={mintedBackground}}
56+
\setminted[text]{bgcolor={mintedBackground},linenos=false,autogobble,xleftmargin=1em}
57+
%\setminted[php]{bgcolor=mintedBackgroundPHP} %startinline=True}
58+
\SetupFloatingEnvironment{listing}{name=Code Sample}
59+
\SetupFloatingEnvironment{listing}{listname=List of Code Samples}
60+
61+
\begin{document}
62+
63+
\section*{CSCE 155 - Lab 04 - Loops - Worksheet}
64+
65+
Names: \underline{\hspace{10cm}}
66+
67+
\begin{questions}
68+
69+
\question Run your sine program and compute the following values.
70+
\begin{parts}
71+
\part $x = 3.1415, n = 1$
72+
\begin{solution}[1cm]
73+
\end{solution}
74+
\part $x = 3.1415, n = 7$
75+
\begin{solution}[1cm]
76+
\end{solution}
77+
\part $x = 1.5707, n = 1$
78+
\begin{solution}[1cm]
79+
\end{solution}
80+
\part $x = 1.5707, n = 5$
81+
\begin{solution}[1cm]
82+
\end{solution}
83+
\part $x = 0, n = 10$
84+
\begin{solution}[1cm]
85+
\end{solution}
86+
\end{parts}
87+
88+
\question Try to compute a sine value using a ``large'' value for $n$, say $n = 100$.
89+
What value do you get? Why do you think that is?
90+
\begin{solution}[3cm]
91+
\end{solution}
92+
93+
\question Play the guessing game at least 3 times to ensure that your program works. What is your best score (that is, least number of guesses)?
94+
\begin{solution}[3cm]
95+
\end{solution}
96+
97+
\question Demonstrate your primes program to a lab instructor, have them sign this worksheet and turn it in.
98+
\end{questions}
99+
100+
Lab Instructor Signature\underline{\hspace{7.5cm}}
101+
102+
\end{document}

handouts/Lab04-Loops.pdf

126 KB
Binary file not shown.

0 commit comments

Comments
 (0)