- using complex if statements to control program execution
- using a while loop for repetition
- input & output of numerical values
- implementing simple numerical calculations

Create a new directory for this lab called `lab04`

by typing:

Change to this directory by typing:mkdir lab04

cd lab04

For example:

As usual autotest is available to help you test your program../three_fiveEnter number:103 5 6 9./three_fiveEnter number:303 5 6 9 10 12 15 18 20 21 24 25 27

~cs1511/bin/autotest lab04 three_five.c

`perfect.c`

that reads a positive integer Autotest is available to help you test your program../perfectEnter number:6The factors of 6 are: 1 2 3 6 Sum of factors = 12 6 is a perfect number./perfectEnter number:1001The factors of 1001 are: 1 7 11 13 77 91 143 1001 Sum of factors = 1344 1001 is not a perfect number

~cs1511/bin/autotest lab04 perfect.c

`x.c`

that reads an integer
You can assume *n* is odd and **>= 5**.

Make your program match the examples below exactly.

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

As usual autotest is available to help you test your program../xEnter size:5*---* -*-*- --*-- -*-*- *---*./xEnter size:9*-------* -*-----*- --*---*-- ---*-*--- ----*---- ---*-*--- --*---*-- -*-----*- *-------*./xEnter size:15*-------------* -*-----------*- --*---------*-- ---*-------*--- ----*-----*---- -----*---*----- ------*-*------ -------*------- ------*-*------ -----*---*----- ----*-----*---- ---*-------*--- --*---------*-- -*-----------*- *-------------*

~cs1511/bin/autotest lab04 x.c

`plus.c`

that reads an integer
You can assume *n* is odd and **>= 5**.

Make your program match the examples below exactly.

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

As usual autotest is available to help you test your program../plusEnter size:7---*--- ---*--- ---*--- ******* ---*--- ---*--- ---*---./plusEnter size:13------*------ ------*------ ------*------ ------*------ ------*------ ------*------ ************* ------*------ ------*------ ------*------ ------*------ ------*------ ------*------

~cs1511/bin/autotest lab04 plus.c

`chessboard.c`

that reads an integer
You can assume *n* is odd and **>= 5**.

Make your program match the examples below exactly.

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

As usual autotest is available to help you test your program../chessboardEnter size:5-*-*- *-*-* -*-*- *-*-* -*-*-./chessboardEnter size:7-*-*-*- *-*-*-* -*-*-*- *-*-*-* -*-*-*- *-*-*-* -*-*-*-./chessboardEnter size:17-*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-* -*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-* -*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-* -*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-* -*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-* -*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-* -*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-* -*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-* -*-*-*-*-*-*-*-*-

~cs1511/bin/autotest lab04 chessboard.c

./prime_factorsEnter number:6The prime factorization of 6 is: 2 * 3 = 6./prime_factorsEnter number:30The prime factorization of 30 is: 2 * 3 * 5 = 30./prime_factorsEnter number:2250122501 is prime./prime_factorsEnter number:2048The prime factorization of 2048 is: 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 = 2048./prime_factorsEnter number:22500The prime factorization of 22500 is: 2 * 2 * 3 * 3 * 5 * 5 * 5 * 5 = 22500./prime_factorsEnter number:2250122501 is prime

**Hint**: prime_factors.c requires a declaring a number of variables
and thinking carefully about how they will be used (choose good names).
If you don't have the right variables, you'll get stuck writing the if and while statements.

**Hint**: prime_factors.c will require difficult debugging - think about where you can **printf** statements to see the value of variables and understand what your program is doing.

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

Autotest is available to help you test your program.

~cs1511/bin/autotest lab04 prime_factors.c

`spiral.c`

that reads an integer
You can assume *n* is odd and **>= 5**.

You are only permitted to use C language features covered in weeks 1-3 lectures. In particular, you are not permitted to use array(s).

Make your program match the examples below exactly.

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

Try to invent your own solution - don't google or ask others how do it. Tutors want to see your original work even if it only partly works./spiralEnter size:5***** ----* ***-* *---* *****./spiralEnter size:7******* ------* *****-* *---*-* *-***-* *-----* *******./spiralEnter size:9********* --------* *******-* *-----*-* *-***-*-* *-*---*-* *-*****-* *-------* *********./spiralEnter size:17***************** ----------------* ***************-* *-------------*-* *-***********-*-* *-*---------*-*-* *-*-*******-*-*-* *-*-*-----*-*-*-* *-*-*-***-*-*-*-* *-*-*-*---*-*-*-* *-*-*-*****-*-*-* *-*-*-------*-*-* *-*-*********-*-* *-*-----------*-* *-*************-* *---------------* *****************

As usual autotest is available to help you test your program.

~cs1511/bin/autotest lab04 spiral.c

`decimal_spiral.c`

that reads an integer
You can assume *n* is odd and **>= 5**.

You are only permitted to use C language features covered in weeks 1-3 lectures. In particular, you are not permitted to use array(s).

Make your program match the examples below exactly.

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

Try to invent your own solution - don't google or ask others how do it. Tutors want to see your original work even if it only partly works - this is a really hard problem../decimal_spiralEnter size:565432 ----1 210-0 3---9 45678./decimal_spiralEnter size:70987654 ------3 87654-2 9---3-1 0-012-0 1-----9 2345678./decimal_spiralEnter size:9876543210 --------9 8765432-8 9-----1-7 0-210-0-6 1-3---9-5 2-45678-4 3-------3 456789012./decimal_spiralEnter size:15654321098765432 --------------1 2109876543210-0 3-----------9-9 4-210987654-8-8 5-3-------3-7-7 6-4-87654-2-6-6 7-5-9---3-1-5-5 8-6-0-012-0-4-4 9-7-1-----9-3-3 0-8-2345678-2-2 1-9---------1-1 2-01234567890-0 3-------------9 456789012345678

As usual autotest is available to help you test your program.

~cs1511/bin/autotest lab04 decimal_spiral.c

`lab04`

directory):
Submit the challenge exercises only if you attempt them.give cs1511 lab04 three_five.c perfect.c x.c plus.c chessboard.c prime_factors.c spiral.c decimal_spiral.c

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

Remember the lab assessment guidelines - if you don't finish the exercises
you can finish them in your own time, submit them
by Monday 11:00am using `give`

and ask your tutor to assess them at the start of
the following lab.

Either or both members of a programming pair can submit the work (make sure each program lists both of you as authors in the header comment).