-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.txt
More file actions
153 lines (118 loc) · 6.12 KB
/
4.txt
File metadata and controls
153 lines (118 loc) · 6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Edit page title -->
<title>CSE 333 25au Exercise 5</title>
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400italic,600' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Inconsolata:400,700' rel='stylesheet' type='text/css'>
<!-- This script dynamically loads CSS and JS files from the course base directory -->
<!-- Only edit if you want to change the paths to your JS/CSS sources -->
<script>
// Get the base path for the course web by extracting 'courses' + courseName + quarter
var fullPathArray = window.location.pathname.split('/');
var basePathArray = fullPathArray.slice(0,4);
var basePath = basePathArray.join('/');
// CSS files to load
var cssSources = [
'/site/css/bootstrap.min.css',
'/site/css/main.css',
];
// Javscript files to load
var jsSources = [
'/site/js/jquery.min.js',
'/site/js/bootstrap.min.js',
'/site/js/nav-bar.js',
'/site/js/footer.js'
];
// Include the script that will load the CSS & Javscript files
document.write("<script src=\'" + basePath + "/site/js/load-sources.js\'><\/script>");
</script>
</head>
<body>
<header class="site-header">
<!-- Javascript will load the navigation bar code here. -->
</header>
<div class="container">
<!-- Begin page content -->
<h1>CSE 333 25au Exercise 5</h1>
<p>
<b>out:</b> Friday, October 3, 2025<br>
<b>due:</b> Monday, October 6, 2025 by <b>10:00 am</b>,
<b>No late exercises accepted</b>.
</p>
<p>
<b>NOTE</b>: we're skipping exercise 4 this quarter, which is just a simplified version of exercise 5. Y'all are just too good!
</p>
<!--
This version of ex5 sucked in the content of ex4 like an amoeba so to make
timing line up better for future exercises. Ex4 should be skipped if this
version of ex5 will be used.
-->
<p><b>Goals: </b>Write a multi-file C program that properly uses header,
implementation, and client files to partition a program. Learn how to compile programs with Make.</p>
<p><b>Description: </b> Your job is to write a multi-file C program. You
should write the following three files:
<ul>
<li><code>NthPrime.h</code>: a header file, containing a single function
prototype declaration for a function called <code>NthPrime()</code>, as
well as comments above the prototype documenting how to use the function.
The function should accept a single <code>int16_t</code> parameter, and
it should return an <code>int64_t</code>. The function should return the
nth prime number, where <code>n</code> is the function's parameter. Note
that <code>NthPrime(1)</code> should return 2, <code>NthPrime(2)</code>
should return 3, <code>NthPrime(3)</code> should return 5, and so on. The
result of <code>NthPrime(n)</code> is not defined if <code>n</code> <=
0, and implementations do not need to check for this possibility. The
header file should include proper header guards.</li>
<li><code>NthPrime.c</code>: a file containing the implementation of
<code>NthPrime</code>. Feel free to use the simplest possible primality
testing algorithm (hint: "x is not prime if it is divisible by ..."). You
may also want to define some helper functions here as well. Use
<code>static</code> to ensure that such helper functions, if any, have
internal, not external linkage and thus are not visible to other files.</li>
<li><code>ex5.c</code>: a file containing a <code>main()</code> function that tests
<code>NthPrime</code> by printing the input and output output of <code>NthPrime</code>
for at least two different, non-trivial arguments (but you do not need to
print an enormous number of test cases - keep it reasonable).</li>
<li><code>Makefile</code>: as explained below.</li>
</ul>
</p>
<p> You should use (and include in your final submission) this unmodified
Makefile: <a href="ex05_files/Makefile">link</a>. Place
the <code>Makefile</code> in your exercise directory and then run the terminal command
<code>make</code> to compile your solution binary. Conversely, run
<code>make clean</code> to delete any files generated by the compiler
(including the final executable). The latter is useful to make sure you're
not accidentally adding any temporary files to a git commit!</p>
<hr>
<p>Your code must:
<ul>
<li> compile without errors or warnings on CSE Linux machines
(lab workstations, attu, or CSE home VM) by running <code>make</code> in the submission directory </li>
<li> have no crashes, memory leaks, or memory errors on CSE linux machines</li>
<li> be pretty: the formatting, modularization, variable and
function names, and so on must make us smile rather than cry.
(Suggestion: see if <code>cpplint --clint</code> reports any problems.
However, you may ignore warnings from <code>cpplint --clint</code> about
the header guard <code>#define</code> name not including a full file path
as long the identifier has an otherwise appropriate name.)</li>
<li> be robust: you should think about handling bogus input
from the user, and you should handle hard-to-handle cases
(if there are any) gracefully.</li>
<li> have a comment at the top of each of your files with your name,
student number, and CSE or UW email address.</li>
</ul>
</p>
<p>
You should submit your exercise using the Gradescope dropbox linked on the
course resources web page.</p>
<!-- End page content -->
</div>
<footer class="site-footer">
<!-- Javascript will load the footer code here. -->
</footer>
</body>
</html>