Description
Objectives:
At the end of the class the students should be able to:
use repetition statements in C programs
Exercise 1:
Write a C program that uses while loop to print the following table of values. Use the tab escape sequence in the printf statement to separate the column with tabs.
N 10*N 100*N 1000*N
- 10 100 1000
- 20 200 2000
- 30 300 3000
- 40 400 4000
- 50 500 5000
- 60 600 6000
- 70 700 7000
- 80 800 8000
- 90 900 9000
- 100 1000 10000
Exercise 2:
The factorial of a nonnegative integer n is written n! and is defined as follows:
n! = n * (n – 1) * (n – 2) * ……1
and n! = 1 (for n = 0)
For example, 5! = 5 * 4 * 3 * 2 * 1, which is 120
Write a C program that reads a nonnegative integer and computes and print its factorial using a while l
Exercise 3
Write a program that prints the following patterns separately. Use for loop to generate the patterns. All asterisks (*) should be printed by a single printf statements.
( a ) (b) (c) ( d )
* ********** ********** *
** ********* ********* **
*** ******** ******** ***
**** ******* ******* ****
***** ****** ****** *****
****** ***** ***** ******
******* **** **** *******
******** *** *** ********
********* ** ** *********
********** * * **********



