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.



Share on Google Plus

About Grace Joseph

Grace Joseph is a tech blogger from Cross River State, Nigeria. She studied Computer Science in University of Calabar and is a lover of tech, music and the Internet. You can follow her on Facebook and Google+

0 comments:

Post a Comment