Problem Solving and Computer Programming

To become more familiar with:

- C program creation, compilation, and execution
- Sequence, Selection, and Repetition Control Structures
- Logical Operators
`if`and`while`instructions in C

For question 1, copy the truth tables below and paste them in a text file named

- (16 points) Fill in the truth tables.

+---+---+------------------------+ | a | b | (!a && b) || (a && !b) | +---+---+------------------------+ | 0 | 0 | | +---+---+------------------------+ | 1 | 0 | | +---+---+------------------------+ | 0 | 1 | | +---+---+------------------------+ | 1 | 1 | | +---+---+------------------------+ +---+---+---+---------------------------------+ | a | b | c | (!(a || b)) && (c || (a || !b)) | +---+---+---+---------------------------------+ | 0 | 0 | 0 | | +---+---+---+---------------------------------+ | 1 | 0 | 0 | | +---+---+---+---------------------------------+ | 0 | 1 | 0 | | +---+---+---+---------------------------------+ | 0 | 0 | 1 | | +---+---+---+---------------------------------+ | 1 | 1 | 0 | | +---+---+---+---------------------------------+ | 1 | 0 | 1 | | +---+---+---+---------------------------------+ | 0 | 1 | 1 | | +---+---+---+---------------------------------+ | 1 | 1 | 1 | | +---+---+---+---------------------------------+ +---+---+---------------------------------+ | a | b | ((a % (b + 1)) == 0) && (b = 0) | +---+---+---------------------------------+ | 0 | 0 | | +---+---+---------------------------------+ | 1 | 0 | | +---+---+---------------------------------+ | 0 | 1 | | +---+---+---------------------------------+ | 1 | 1 | | +---+---+---------------------------------+

- (59 points)
Write a C program,
`campusid_tri.c`, that will print out a triangle of *'s, where only the odd numbered lines are printed. The height of the triangle should be input by the user, and should be checked to ensure that the height is positive and odd. If the input value is inappropriate, the user should be prompted until the input value is correct.

When printing the triangle, only the odd numbered lines (i.e. 1, 3, 5, ...) should contain *'s and the even lines should be blank (but included). The number of *'s printed on the odd lines should be equal to the line number. As an example, a triangle of height 13 is given below.

* *** ***** ******* ********* *********** *************

- (10 points optional
**EXTRA CREDIT**) Make a copy of your completed`campusid_tri.c`called`campusid_isosceles.c`and modify it such that the printed triangle is isoceles rather than right. The other characteristics of the triangle should remain the same (even lines blank, number of *'s equal to the line number, etc). As an example, a triangle of height 13 is given below.

* *** ***** ******* ********* *********** *************

When you have finished, submit your

(optional)

Additionally, email your