CS209 lab1
http://www.maths.nuigalway.ie/~gettrick/teach/cs209/l1.html
-
For this lab you should submit all source code (C
files), and the result(s) of running the program on (a few)
test cases.
The source code must
be well presented (indenting, spaces, reasonable variable/function names,
etc.) and must include comments (as a rough guideline - aim to have nearly as
many comments as lines of code).
-
The above material should be uploaded to BLACKBOARD
before
the deadline of 5pm
Wednesday 2nd. February 2011. You will lose 20% for each day
(or part of day) the lab is late.
-
Plagiarism (the unattributed copying of work from other sources
(internet, fellow students,....)) will not be tolerated. Please see
http://www.nuigalway.ie/engineering/documents/plagiarism_guide_students
_v4.pdf. You risk getting zero for your lab if it is found to be
plagiarized.
-
You should first experiment with some of the simple programs at
http://www.maths.nuigalway.ie/~gettrick/teach/cs209/progs/.
-
Write a program in C (or adapt one of the existing ones) that calculates the median of a set
of distinct input integers (input at the command line). The median is some number x such that half the
numbers are above x and half below. For example,
- median of 1,3,5,7 is 4
- median of 1,2,2,7 is 2
- median of 1,2,3,7 is 2.5
(note - as in the last example - the median may not necessarily be an integer).
-
Adapt your program to check that in the input list, no two numbers are repeated, and if they are
print a helpful message to the user.
-
(GIGO! (garbage in,....))
Adapt your program so that if the user types in "garbage" as command line arguments, a helpful message
is returned on how to run the program.
©
NUI, Galway