COMP1511 18s1 (webcms)
COMP1511 18s1 (flask)

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:
Any violation of the test conditions will results in a mark of zero for the entire weekly test component.

Print A Smiley

Write a program smiley.c which prints an smiley exactly as below.

Your program should behave as follows:

dcc -o smiley smiley.c
./smiley
:-)

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

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

Print the Difference Between two Integers

Write a C program difference.c that reads 2 integers and prints their difference.

If they are equal it should print "equal".

Your program should behave exactly like this example:

dcc -o difference difference.c
./difference
7 15
8
./difference
105 67
38
./difference
42 42
equal
Note your program does 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 either a single positive integer or the word equal.

You can assume the user supplies 2 integers. You do not have to check the return value from scanf.

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

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

Are these The Sides of a Triangle

Write a C program is_triangle.c to read 3 numbers and indicate whether they can be the sides of a triangle.

Reminder: 3 numbers can be the sides of a triangle if the sum of any two of the numbers is larger than the third.

Your program should behave exactly like this example:

dcc -o is_triangle is_triangle.c
./is_triangle
Please enter three numbers: 5.6 6.5 11.9
triangle
./is_triangle
Please enter three numbers: 12.5 5.6 6.5
not a triangle
./is_triangle
Please enter three numbers: 1.5 1.5 1.5
triangle
./is_triangle
Please enter three numbers: 1.5 42.0 1.5
not a triangle
You can assume the user supplies 3 positive numbers. You do not have to check the return value from scanf.

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

1511 autotest is_triangle
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test03_is_triangle is_triangle.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 Wednesday 21 March 23:59:59 to complete this test.

Automarking will be run several days after the submission deadline for the test. When complete you can view automarking here and you can view the the resulting mark via give's web interface