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

  • Files spread between Dropbox, Google Drive, Gmail, Slack, and more? Dokkio, a new product from the PBworks team, integrates and organizes them for you. Try it for free today.

View
 

Array Exercise 1b Solution

Page history last edited by Steve Sweeney 10 years, 10 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.