You are on page 1of 2

Repetition

1. Define and explain briefly on pretest loop and a post-test loop using the flowchart. 2. Compare a pretest loop and post-test loop. 3. Determine the output for the below program segments without using C compiler. a. i. y = 8; while (y>7) { printf (%d\n, y); } ii. for (int k = 10; k > 8;) { printf (%d\n, k); }

iii. z = 3; do { printf (%d\n, z); } while (z<9);

b. Rewrite the missing loop update in the above program segments.

4. Write a program to produce the below output: *+*+*+*+*+ *+*+*+*+ *+*+*+ *+*+ *+ 5. Write a program to produce the below output:
^*********

^^******** ^^^******* ^^^^****** ^^^^^***** ^^^^^^**** ^^^^^^^*** ^^^^^^^^** ^^^^^^^^^* ^^^^^^^^^^

Discussion: What will happen if C does not have repetition statement?

You might also like