Submit a single file UserID.assignment1.tar to cuLearn.
Replace UserID with your 9-digit Carleton student ID number. Use the tar
program (see pg 85 of the Linux Phrasebook)
to create the tar file (similar to a zip file). It should contain the modified
Makefile
from problem 0 and all
program?.c
files
for the coding questions.
Your grade for this assignment will be based on correctness and style.
Edited Monday, January 28
Download the following Makefile. Add one rule for the submit target at the bottom of the Makefile as
specified in the file.
If you include the math library
We will compile with a version of GCC that does not need
the
Edited Sunday, January 27
Write a C program, called
For example, if the input, entered from the keyboard, was
Note: Just use Note: You can assume that the input will only consist of letters, digits, and whitespace (space, tab, linefeed, etc).
Write a C program, called
The output should be a single line that looks exactly like
Note: Use the sample standard deviation (which uses N-1 instead of N in the denominator inside the square root of the formula).
Note: Do not use an array for this question.
Write a C program, called
For example, if the input, entered from the keyboard, was
Write a C program, called
The validation procedure can be found at http://en.wikipedia.org/wiki/Social_Insurance_Number#Validation.
Write a C program, called
For example, the input
-lm
at
the end of your rule for any of the targets. Otherwise, do not change
anything else in the Makefile.
We will use this Makefile when compiling your code (and you should too).
-lm
so don't worry if your submission needed this.
problem1.c
, that reads
(and processes) characters from standard input until a 'Q' is reached.
Each letter and digit read should be printed to standard output (including the Q).
The output will consist of a single line of characters (letters and digits), with no extra white-space added,
ending with Q and then a newline.
a[return]
b[return]
Q[return]
then the output would be the single line
abQ
with a newline at the end of the output. The same output would be given for the input
abQ[return]
and
a[return]
bQ[return]
scanf()
and printf()
. You can use other functions if you wish but these are sufficient.
problem2.c
, that computes the average and standard deviation of
a collection of numbers entered from standard input.
The program reads zero or more non-negative decimal numbers (double
s) followed by the decimal number -1.0
.
Once -1.0 is entered, the program
prints to standard output the average and standard deviation of all the non-negative numbers entered and the main function returns 0.
average,standard_deviation
where average
is the average of the numbers and standard_deviation
is the
standard deviation. Both of these are double
s.
There should be no spaces around the comma and the line should end with a newline character.
problem3.c
, that reads a single integer n
from standard input and then
reads n
more integers. After reading all the integers the program displays all the integers (one integer per line)
in the reverse order that they were read.
3[return]
12[return]
-9[return]
1[return]
then the output would be three lines
1
-9
12
problem4.c
, that validates Canadian Social Insurance Numbers. The program repeatedly
reads an unsigned integer from standard input until the number 0 is entered. For each number entered, the program will
display "valid" or "invalid" on a single line, depending if the number entered is valid or invalid, and then read another
number from standard input (or exit the program if 0 is entered).
problem5.c
, that reads characters from standard input until three consecutive 'Q' characters are read.
The program processes the read characters and gives output to standard output as follows:
'_'
'\'
is immediately followed by 'n'
then replace these two characters
with the newline character '\n'
(and do not do any case conversion). This does not apply if
N
follows the slash character.
'\'
characters appearing consecutively in the input
abcABCAA\n3\N6-QQQ[return]
will give the output
ABCabca2
6\n18-
where the newline character is unseen but causes an actual newline.
Last modified : January 23rd, 6:45pm