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

Loading...
Loading...

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.

Loading...

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 an educational and tech blogger. Other than having passion for gadgets and generally the tech niche, she's a writer at heart and reading is forever a hobby.

0 comments:

Post a Comment

Please share your views on this topic with Grace Joseph by leaving a comment.