CSCI 150, Spring 2003
Home | | Course Schedule | | Assignments | | Lecture NotesLab 5 solution
{program: initials.pas Author: Brenda Student Class: CSCI 150, Section 03 Date: 2/26/03 Purpose: Use procedures to print initials} program initials; procedure printSpaces( num: integer); var count: integer; begin for count := 1 to num do begin write(' '); end; end; {end of printSpaces } procedure printLetters( number: integer; letter: char); var count: integer; begin for count := 1 to number do begin write(letter); end; end; {end of printLetters} procedure writeC; begin printSpaces(1); printLetters(6, 'C'); writeln(); printLetters(1, 'C'); writeln(); printLetters(1, 'C'); writeln(); printLetters(1, 'C'); writeln(); printLetters(1, 'C'); writeln(); printLetters(1, 'C'); writeln(); printSpaces(1); printLetters(6, 'C'); writeln(); end; {end of WriteC} begin writeC; end. {end of initials}
{program: gradeAvg.pas Author: Brenda Student Class: CSCI 150, Section 01 Date: 2/19/01 Purpose: Computes grade average from test scores} program computeGrade; function GradeAverage( num: integer): real; var count: integer; sum: real; score: real; begin sum := 0; for count := 1 to num do begin write('Enter test score: '); readln(score); sum := sum + score; end; GradeAverage := sum/num; end; {end of GradeAverage } var numScores: integer; average: real; begin writeln('How many scores do you want to enter?'); readln(numScores); average := GradeAverage(numScores); writeln('The average score is ', average:10:2); end. {end of computeGrade }