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 The Middle Integer of 3 Integers

Write a C program middle3.c that reads 3 integers and prints the middle integer.

You are not permitted to use loops or arrays (use if statements).

Your program should behave exactly like this example:

./middle3
Enter integer: 23
Enter integer: 5
Enter integer: 27
Middle: 23
./middle3
Enter integer: 3
Enter integer: 6
Enter integer: 27
Middle: 6
./middle3
Enter integer: 9
Enter integer: 7
Enter integer: 8
Middle: 8
You can assume the user supplies 3 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 middle3
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test04_middle3 middle3.c

Print an 'L'

Write a program called l.c that reads an integer n from standard input. and prints a pattern of asterisks in the shape of an "L".

You can assume n is positive.

Make your program match the examples below exactly.

You are not permitted to use arrays in this exercise.

./l
Enter size: 2
*
**
./l
Enter size: 5
*
*
*
*
*****
./l
Enter size: 9
*
*
*
*
*
*
*
*
*********

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

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

Print A Hollow Triangle

Write a program called hollow_triangle.c that reads an integer n from standard input. and prints a pattern of asterisks forming a hollow triangle.

You can assume n is greater than 3.

Make your program match the examples below exactly.

You are not permitted to use an array in this exercise.

dcc hollow_triangle.c -o hollow_triangle
./hollow_triangle 
Enter size: 4
*
**
* *
****
./hollow_triangle 
Enter size: 5
*
**
* *
*  *
*****
./hollow_triangle
Enter size: 8
*
**
* *
*  *
*   *
*    *
*     *
********
./hollow_triangle
Enter size: 11
*
**
* *
*  *
*   *
*    *
*     *
*      *
*       *
*        *
***********

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

1511 autotest hollow_triangle
When you are finished working on this exercise you must submit your work by running give:
give cs1511 test04_hollow_triangle hollow_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 Friday 30 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