| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Array Exercise 1b Solution

Page history last edited by Steve Sweeney 11 years, 4 months ago

% store 10 student grades

var grades : array 1 .. 10 of int

var totalGrades : int := 0

% ask user for each student grade

put "Please enter grades for 10 courses"

put "=================================="

for i : 1 .. 10

    put "Grade #", i, ": "..

    get grades (i)

end for

% print out list of grades

for i : 1 .. 10

    put "Grade #", i, " ==> "..

    put grades (i)

end for

for i : 1 .. 10

    totalGrades := totalGrades + grades(i)

end for

put "Average = ", totalGrades/10

Comments (0)

You don't have permission to comment on this page.