Basic help needed again. 
Author Message
 Basic help needed again.

Once again it's the pesky learner from NZ.  I'm working on an assignment
which requires me to use "While" loops.  My program seems to work ok except
for the fact that once the program is completed, it starts all over again.
In other words, I can't figure out where to put the termination point for
the statements in the loop.  Any help would be greatly appreciated.

Source code follows:

Uses Wincrt;

Var
   Count  :  Integer;   {Number of marks}
   Marks  :  Integer;   {Value to be inserted into the array}
   Markno :  Array [1..10] Of Integer;  {List in which marks are stored}
   Loop   :  Integer;   {Loop counter}
   Max    :  Integer;   {Used for finding highest mark}
   Min    :  Integer;   {Used for finding lowest mark}
Begin
     Clrscr;
     Writeln('STUDENT MARK ANALYSIS');  {Displays program name}
     Writeln('=====================');

     Writeln;
     Write('How many marks will be input? : '); {Prompts user to input
number of marks for analysis}
     Readln(Count);                             {Reads input from user}
     Writeln;
While Count <= 10 Do
Begin
     Begin
          For Loop := 1 to Count Do     {Loop used to display prompt for
inputting of marks and processing the input}
          Begin
               Write('Enter student mark ', Loop, ' : ');
               Readln (Marks);           {Reads input from user}
               Markno [Loop] :=Marks;
          End;
     End;
                                        {Loop used to calculate average
student marks}
     Begin
          Writeln;
          Marks := 0;
          For Loop := 1 to Count Do
          Begin
               Marks := Marks + Markno[Loop];
          End;
          Writeln('Average student mark = ',Marks Div Count);
          Min := 100;
          For Loop := 1 To Count Do
          Begin
               While Min > Markno[Loop] Do
               Begin
                    Min := Markno[Loop];
               End;

          End;
          Writeln('Lowest  student mark = ',Min);
          Max := 0;
          For Loop := 1 to count do
          Begin                         {Loop used to calculate lowest
student marks}
               While Max < Markno[Loop] Do
               Begin
                    Max := Markno[Loop];
               End;

          End;                          {Loop used to calculate highest
student marks}
          Writeln('Highest student mark = ',Max);
          Writeln(#10#13+'END OF PROGRAM');
     End
End;

     Begin
          Writeln;
          Writeln('INVALID NUMBER OF MARKS!');  {Displayed if user inputs
more than 10 marks}
          Writeln;
          Writeln('END OF PROGRAM');
     End;

Cheers,

Gavin.



Fri, 14 Oct 2005 16:06:13 GMT  
 Basic help needed again.
Hi,

Quote:
>      Readln(Count);                            {Reads input from user}

'count' will never change in the rest of the program.

Quote:
> While Count <= 10 Do

Therefore "count<=10" will ever be true (or false), this loop will either  
always or never be executed.

I could not see the reason for this loop. Do you only want to check that  
"count" fits to the range of "markno" which is an array [1..10]? If so,  
use:

if count <= 10 do
begin
  [ calculate something ]
end
else begin

Quote:
>    Writeln('INVALID NUMBER OF MARKS!');  {Displayed if user inputs

end;

--
shine on ...

      -=< Moe >=-



Fri, 14 Oct 2005 17:13:00 GMT  
 Basic help needed again.


at Mon, 28 Apr 2003 20:06:13 :-

Quote:
>Once again it's the pesky learner from NZ.  I'm working on an assignment
>which requires me to use "While" loops.  

By learning not to multi-post, and by asking only in newsgroups
appropriate for the version of Pascal you are using, you could become
less pesky.

Read "The weekly FAQ item about the Pascal newsgroups' reorganization",
cross-posted to these newsgroups.

--

  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt>  RAH Prins : c.l.p.b. mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.



Sat, 15 Oct 2005 04:09:31 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Basic help needed again.

2. I need help programming a basic book library system

3. Basic to intermediate help needed.

4. Basic to Pascal::: Need Help!!!!!!!

5. Basic to Pascal::: Need Help!!!!!!!

6. Need Help again <* urgent *>

7. Need Help again <* urgent *>

8. Hello...Me again...I need help with pascal

9. I NEED HELP AGAIN!!

10. Need help again

11. Help (again) needed on calculating SYSTEM DATE

12. BASIC, VISUAL BASIC, C++, DELPHI SOFTWARE FRO CHEAP PRICE

 

 
Powered by phpBB® Forum Software