Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Seven steps in designing a program

1.Contract Giving a meaningful name to the program by stating what kind of information it consumes and produces. Example: areaofRectangle: Number, Number Number

Name of the program Type of

Type of Input 2

Type of Result

Input 1 2.Header

It restates the program's name and gives each input a distinct name. These names are variables and are referred to as the program's PARAMETERS. Example: areaofRectangle(numLength, numBreadth) 3.Purpose A brief comment of what the program is to compute. Example: To compute the area of a rectangle whose length and width are numLength and numBreadth. 4. Program Examples To gain a better understanding of what the program should compute, we make up examples of inputs and determine what the output should be. Example: areaofRectangle(15,10)150 5. Algorithm A precise step by step plan for a computational procedure that begins with an input value and yields an output value in a finite number of steps Example Procedure areaofRectangle

Declare numLength, numBreadth, numArea Step 1. Get the values for numLength and numBreadth Step 2. Compute the product of numLength and numBreadth and store it in numArea. Step 3. Display the content of numArea Step 4. Stop. 7. Testing Testing can reveal syntax errors, run-time problems, and logical mistakes. Test Case Number TC 01 TC 02 Input 10,15 10,10 Expected Output 150 100 Observed Output 150 120 Status Pass Fail

You might also like