Vous êtes sur la page 1sur 1

CSEB113 Principles of Programming

________________________________________________________________________________

LAB 7: LOOPING PART 2: dowhile AND for LOOP


For each problem below: a) Analyze the problem by identifying input, output, formula, and constraint b) Design an algorithm to solve the problem using pseudocode (so that you could include the pseudocode in your program) c) Prepare several, appropriate number of test data to verify the correctness of your program d) Prepare, compile, link, and execute the program to solve the problem e) Test your program using the prepared test data f) Write proper documentation in the program. Include the following information to form a banner at the beginning of your program:
/****************************************************** * Authors: your name and student ID * * Course: the course code only * * Section: your specific section number * * Date: of lab session * * Brief description: of what problem the * * program tries to solve * * Test data: provide a set of test data * * - input & expected output * ******************************************************/

QUESTIONS 1. Re-write the program of Lab6 Question 2 using do..while loop. 2. Re-write the program of Lab6 Question 2 using for loop. 3. Re-write the program of Lab6 Question 4 using do..while loop. 4. Re-write the program of Lab6 Question 5 using for loop. 5. Re-write the program of Lab6 Question 6 using do..while loop. 6. Improve the program of Lab6 Question 2 (which is supposedly written by implementing a while loop) by implementing proper input data validation. In the new program, using another set of while loop, informs the users should they have entered a wrong input and tells the users to reenter the input. A sample input and output of the program is as follows:
How many times do you want to print the message?: 0 Invalid data. Please re-enter. The value to be entered must be greater than zero How many times do you want to print the message?: 2 Congratulation! You now know how to write a simple C program. Congratulation! You now know how to write a simple C program.

7. Re-write the program in (6) by implementing proper input validation using for loop. 8. Re-write the program in (6) by implementing proper input validation using do..while loop.
-BS-May 2012 1

Vous aimerez peut-être aussi