# Computing

## CONTENTS OF CURRICULUM UNIT 81.06.04

- Introduction
- The Meaning of Area
- Area of a Rectangle
- Computer Programs to Calculate the Area of a Rectangle
- Area of a Square
- Computer Programs to Calculate the Area of a Square
- Area of a Parallelogram
- Computer Programs to Calculate the Area of a Parallelogram
- Area of a Triangle
- Computer Program to Calculate the Area of a Triangle
- Area of a Trapezoid
- Computer Program to Calculate the Area of a Trapezoid
- Bibliography for Teachers
- Student Reading List

### Unit Guide

## Introducing Computer Programming in a Traditional Classroom

Your feedback is important to us!

After viewing our curriculum units, please take a few minutes to help us understand how the units, which were created by public school teachers, may be useful to others.

*
Computer Programs to Calculate the Area of
*
a
*
Parallelogram
*

Program5introduces the concept of a counter when an operation is being performed many times. The counter I keeps a record of the number of times the operation has been performed. 10 REM FIND THE AREA OF FIFTEEN PARALLELOGRAMS 11 PRINT “BASE”, “ALTITUDE”, “AREA” 15 PRINT 18 LET I - 1 20 READ B, H 30 LET A = B*H 40 PRINT B,H,A 50 LET I = I+ 1 60 IF I 16 THEN 20 70 DATA 24,15,46,37,8,6,98,60,36,28,99,75,42,36 71 DATA 9,5,43,29,65,82,18,20,94,78,8,5,19,24,7,5 72 DATA 15,14,23,8,34.6,98.7,104.2 80 END Result: BASE ALTITUDE AREA 24 15 360

###
*
Explanation of Program
*
5:

Line 18 initializes the counting process. I = 1 indicates that the area of the first parallelogram is about to be calculated. Line 50 I = I+ 1 instructs the computer to advance to the next parallelogram. Line 60 reroutes the computer back to line 20 to find the area of the new parallelogram provided the number of the parallelogram has not exceeded 15. As soon as I >15 the program will stop. Line 70 Although more than 15 sets of values for B 71 and H have been given, only the first 15 sets 72 of data will be used. Program6introduces the concept of a dimension statement and subscripted variables. 4 REM AREA OF ANY NUMBER OF PARALLELOGRAMS 5 PRINT “BASE”, “ALTITUDE”, “AREA” 6 PRINT 10 DIM B(100), H(100), A(100) 20 READ N 30 FOR I = 1 TO N 40 READ B(I), H(I) 50 LET A(I) = B(I)* H(I) 60 PRINT B(I), H(I), A(I) 70 NEXT I 80 DATA 14,23,34,46,57,65,78,86,98,76,56,74,88 81 DATA 90,12,34,56,78,86,122,204,368,456,765 82 DATA 215,332,445,895,766,34,68,88,66 90 END

Result: | BASE | ALTITUDE | AREA |

23 | 34 | 782 | |

46 | 57 | 2522 | |

65 | 78 | 5070 | |

86 | 98 | 8428 | |

76 | 56 | 4256 | |

74 | 88 | 6512 | |

90 | 12 | 1080 | |

34 | 56 | 1904 | |

122 | 204 | 24888 | |

368 | 456 | 167808 | |

765 | 215 | 164475 | |

332 | 445 | 147740 | |

895 | 766 | 685570 |

###
*
Explanation of Program
*
6:

Line 10 DIM is an abbreviation for DIMENSION. The DIM statement tells the compiler how many locations to reserve for a subscripted variable. DIM B(100) tells the compiler to reserve 100 memory locations for the values of B(1), B(2), etc. More locations may be reserved than are actually needed. Line 20 instructs the computer to read the first value given in the data line. This is the actual number of locations that will be used from the 100 locations reserved in line 10. Line 30 indicates that I will count the parallelograms from 1 to the value assigned to N. Line 40 introduces It tells the computer to assign the second value in the data line to B(1), the third value to H(1), the fourth value to B(2), the fifth value to H(2), and so on. Line 50 provides the formula to find the areas of the parallelograms. Line 60 instructs the computer to print the values of B(I), H(I), and A(I) in tabular form under the proper headings given in line 5. Line 70 advances the process to the next parallelogram. This will continue until the process has taken place N times.