Sunday, February 14, 2016

Average of Ten Numbers Using Array in Turbo Pascal 6.0

Pascal programming language is the first programming language that I have learned during my first years and second year in college taking up my course in Bachelor of Science in Computer Science in the University of Negros Occidental - Recoletos, Bacolod City, Philippines. 

I find this programming language very easy to learn primary reason is that it uses commonly used english words and terms very near to user understand indeed. I learned many things in Pascal that I was able to used it in learning other programming language such as C, C++, BASIC and among others.

In this sample program that I wrote using Pascal as my programming language and Turbo Pascal 6.0 as my Pascal compiler. This program will ask the user to give ten numbers and then our program will find the average of the ten number being provided by the user using one dimensional array in Pascal.

The program itself is very easy to understand and very useful for those who wants to learn Pascal programming. I know now a day's programming in Pascal is not popular compared to the past 20 years. I just try my best to share the things that I learned before in Pascal programming.


If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output



Program Listing


Program Average_Ten_Numbers;
Uses Crt;
Var
  NumberArray : Array[1..10] of Integer;
  Average : Real;
  i : integer;

Begin
  Clrscr;
  Gotoxy(24,2);
  Writeln('Average of Ten Numbers in Pascal');
  Writeln;

  For i :=  1 To 10 Do
    Begin
      Write('Enter Item No. ' ,i, ' : ');
      Readln(NumberArray[i]);
    End;

  Average := 0;
  i := 1;

  Repeat
    Average := Average + NumberArray[i];
    i := i + 1;
  Until i > 10;

  Average := Average / 10;
  Writeln;
  Writeln('The average is : ',Average:0:2);
  Writeln;
  Writeln(' Thank you for using This Software');
  Readln;
End.




No comments:

Post a Comment