Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 1 decade ago

Anybody know how to write this computer program in Pascal Language?

Write a program in the Pascal language that allows the user to enter five numbers in the range 1 to 20. These five numbers are to be stored in an array. The program will then print on the screen the five numbers starting from the last number inputted to the first number inputted. Calculate the average of all the 5 numbers and display on screen. Then calculate the square root of the total of the five numbers and display it on screen. Include in-line comments.

Update:

Ok I'm sorry guys I tend to laze off sometimes

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    Hi there,

    :D

    No offense to those that do; but it's a shame no-one uses Yahoo Answers for what it was intended; "answering peoples questions".

    To me, personally, it doesn't matter what your question relates to, homework or other. You're asking a question, because you don't know the answer and you need help; so don't feel guilty just because "they" say so. If "they" are unwilling or unable to help those that ask questions on here, perhaps "they" shouldn't waste their time answering questions at all.

    If you need help understanding the code below, (I presume you have taken some lessons?), then feel free to mail me at mystic.smeg@yahoo.co.uk and I'll be happy to help (as I am happy to help anyone). Let me know if you're using a different compiler.

    na

    {program written for Turbo Pascal 7, compiled and tested}

    program Numbers;

    uses Crt;

    var Nums: array[1..5] of integer;

        i,avg: integer;

        sqr: real;

    begin

    {clear the screen}

      ClrScr;

    {start loop (loop 5 times, i is counter)}

      for i:=1 to 5 do

      begin

        Write('Please enter number ',i,' [1-20]: ');

        ReadLn(Nums[i]);

      end; {while}

    {list numbers in reverse}

      for i:=5 downto 1 do

        WriteLn(Nums[i]);

    {calculate the average}

      avg:=0;

      for i:=1 to 5 do

        avg:=avg+Nums[i];

      avg:=avg div 5;

      WriteLn('The average is ',avg);

    {calculate the square root of the total}

      avg:=0;

      for i:=1 to 5 do

        avg:=avg+Nums[i];

      sqr:=Sqrt(avg);

      WriteLn('The square-root of ',avg,' is ',sqr:3:2);

    {wait for user to press a key}

      WriteLn('press any key to exit...');

      ReadKey;

    end.

    Source(s): Please remember to award Best Answer if it works for you. :)
Still have questions? Get your answers by asking now.