Week 03 Weekly Test Questions

Test Conditions

These questions must be completed under self-administered exam-like conditions. You must time the test yourself and ensure you comply with the conditions below.

You may access this language documentation while attempting this test:

You may also access manual entries (the man command).

Any violation of the test conditions will results in a mark of zero for the entire weekly test component.


weekly test question:
Print A Confused Face

Write a program confused.c which prints a confused emoji exactly as below.

Your program should behave as follows:

dcc -o confused confused.c
./confused
:-/

When you think your program is working you can autotest to run some simple automated tests:

1511 autotest confused
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test03_confused confused.c

weekly test question:
Print the Absolute Multiple of Two Integers

Write a C program multiply.c that reads 2 integers and prints their absolute multiple.

That means, given a and b as inputs, it should print the absolute value of a times b. If this is zero, it should print the word "zero" instead.

Your program should behave exactly like this example:

dcc -o multiply multiply.c
./multiply
7 10
70
./multiply
10 -6
60
./multiply
42 0
zero
Note: your program should not print a message asking the user for input.

Your program should write exactly one line of output.

This line of output should contain only a positive integer or the word zero.

You can assume the user supplies two integers. You do not have to check the input is valid.

When you think your program is working you can autotest to run some simple automated tests:

1511 autotest multiply
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test03_multiply multiply.c

weekly test question:
Print The Direction of Three Numbers

You are not permitted to use arrays to answer this question - it can be completed with only the material taught in weeks 1 and 2.

Write a C program upside_down.c to read 3 numbers and indicate whether they are strictly increasing (called "up"), strictly decreasing (called "down"), or neither ("neither"). Reminder: "Strictly Increasing" means that each number is larger than the previous (the sequence "3 4" is strictly increasing, but "3 3" is not). "Strictly Decreasing" means that each number is less than the previous (the sequence "3 2" is strictly decreasing, but "3 3" is not).

Your program should behave exactly like this example:
dcc -o upside_down upside_down.c
./upside_down
Please enter three numbers: 5.6 6.5 11.9
up
./upside_down
Please enter three numbers: 12.5 5.6 6.5
neither
./upside_down
Please enter three numbers: 1.5 1.5 2.5
neither
./upside_down
Please enter three numbers: 70.5 42.0 -1.5
down
You can assume the user supplies 3 doubles. You do not have to check if the input is valid.

When you think your program is working you can autotest to run some simple automated tests:

1511 autotest upside_down
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test03_upside_down upside_down.c

Submission

When you are finished each exercise make sure you submit your work by running give.

You can run give multiple times. Only your last submission will be marked.

Don't submit any exercises you haven't attempted.

If you are working at home, you may find it more convenient to upload your work via give's web interface.

Remember you have until Week 4 Thursday 17:00 to complete this test.

Automarking will be run by the lecturer several days after the submission deadline for the test, using test cases that you haven't seen: different to the test cases autotest runs for you.

(Hint: do your own testing as well as running autotest)

Test Marks

After automarking is run by the lecturer you can view it here the resulting mark will also be available via via give's web interface or by running this command on a CSE machine:

1511 classrun -sturec

The test exercises for each week are worth in total 1 marks.

The best 7 of your 8 test marks for weeks 3-10 will be summed to give you a mark out of 7.