Pascal Program to Find The Average Of Only Positive Numbers Using While Do loop andrey суббота, 12 апреля 2014 г. No Comment

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.

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.

by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

No Comment