0

can someone please help me with this pascal program, does this look right?

Program StudentScores;

var
c: integer;
s: integer;
t: integer;
n: integer;
p: integer;
f: integer;
h: integer;
l: integer;
ave: integer;
max: integer;
am: integer;
hi: integer;
li: integer;
scores: integer;

Begin
      For c:= 1 to 15 do;
         Begin
              writeln('Enter the name of student: ',n);
              readln(n);
              writeln('Enter the test scores for Class A: ',s);
              readln(s);
              If scores > 80 then
              writeln('This student gets an A: ',p)
              Else
              writeln('This student has Failed: ',f);
              read(scores);
         End;
              scores:=0
              max:=0
              read(scores);
        Begin
              writeln('The highest score is: ',h);
              read(h);
              writeln('The lowest score is: ',l);
              read(l);
              Writeln('Enter all students who have an A: ',a);
              read(a);
              writeln('Enter all students who failed: ',failed);
              read(failed);
              ave:=scores/15;
              read(ave);
         End;
         For c:= 1 to 15 do;
         Begin
           writeln('Enter the name of student ',n);
              readln(n);
              writeln('Enter the test scores for Class B ',s);
              readln(s);
              If scores > 80 then
              writeln('This student gets an A ',p);
              Else
              writeln('This student has Failed ',f);
              read(scores);
         End;
              scores:=0
              max:=0
              read(scores);
        Begin
              writeln('The highest score is ',h);
              read(h);
              writeln('The lowest score is ',l);
              read(l);
              Writeln('Enter all students who have an A ',a);
              read(a);
              writeln('Enter all students who failed ',failed);
              read(failed);
              ave2:=scores/15;
              read(ave2);
         End;
         Begin
              average mark:=ave+ave2/2
              writeln('The average mark is ',am);
              readln(am);
              writeln('The highest individual mark is ',hi);
              readln(hi);
              writeln('The lowest individual mark is ',li);
              readln(li);

          End;
          Readln;
          Readln;

End.

2
Contributors
1
Reply
6
Views
11 Months
Discussion Span
Last Post by SalmiSoft
0

Without knowing what the program is supposed to do it is difficult to judge if it looks right. However there are one or two things worth commenting on regardless of that.

First, I suggest you use meaningful variable names because c, s, t, n, p, f, h, and l tell nothing about the values they will hold.

Second, the semi-colon at the end of the line:

For c:= 1 to 15 do;

Probably should not be there. It means this line is the same as:

For c:= 1 to 15 do {nothing};

I guess you want the repeat the following begin...end block 15 times, not the null statement before the semicolon. You repeat the same logic later in the code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.