Pascal Program to Find The Average Of Only Positive Numbers Using While Do loop

Using the while do loop, the program calculates the sum and average of only three positive numbers. Any negative number entered by the user is ignored.

Program Positve;
Label 10;
Var
Sum, Ave, N: real;
I : integer;

Begin
I:=0; sum:=0;
While i<=3 do
Begin
10: Writeln ('enter the numbers');
       Readln (N);
        If N < 0 then goto 10
          Else
          Sum:= sum + N;
          I:= i+1;
          End;

        Ave:= sum/3;
    Writeln ('the average',ave);
     Readln;
     End.


Subscribe to TECHLASS by Email



Do you like this post? Please link back to this article by copying one of the codes below.

URL Of Post:


HTML Link Code:

BB (forum) link code:

Share on Google Plus

About Grace Joseph

Grace Joseph is from Cross River State, Nigeria. She studied Computer Science in University of Calabar and has great passion for writing, technology and blogging.

0 comments:

Post a Comment