The problem is that I am not sure how to load the data from keyboard to a two dimentional array when column number is unknown. Specifically, I need a program to store students’ grades for 4 subjects whithout knowing the actual number of students.
I have come up with this (I am fairly certain that the decision is faulty, but it’s the best I’ve got so far):
Declare Grades as dynamic two dimentional array of int
Loop: Subject = 1 to 4
Print 'Enter students grades for subject' + Subject#
Print 'Enter * when done'
If Grades <=100 && Grades >=0 then
While Grades <> '*'
Enter Grades w/o cursor return
WhileEnd
Else
Print 'Enter a valid grade'
EndIf
LoopEnd: Subject
I guess that it’s not clear from this code how the Subject loop functions, i.e. when it goes from subject1 to subject2 and so on. I initially thought that to achieve the goal I would simply need to return cursor (which would have been done after a user entered ‘*’), but it’s hardly true, is it?
So could you please-please help me understand this problem better?
Thank you.
A couple of things are wrong with your pseudocode:
If you’ll like to iterate over the subjects and then the students, you could do it this way: