Discussion:
Need help please.....
(too old to reply)
Chris Muyna
2019-09-24 08:27:32 UTC
Permalink
1. Write a program called Sum and Average to produce the sum of 1,2,3,...
to an upper bound (e.g 100). Also compute and display the average.


the sum is 5050
the average is 50.5



anyone can me a scrip about that question? PASCUL TURBO
David Snowdon
2019-09-25 13:28:32 UTC
Permalink
Below is code that will perform the task you have specified:

+++++++++++++++++++++++++++++

PROGRAM Successive_Sum;

Uses Crt;

Var sum, value, tmp : INTEGER;
avg : SINGLE;


BEGIN
ClrScr;
Writeln('Program to find the sum of 0, 1, 2, 3, ...');
Writeln;
Write('Enter stop value ');
Readln(value);
Writeln;

sum := 0;
For tmp := 0 to value Do
sum := sum + tmp;

Writeln('The sum from 0 to ', value, ' is ', sum);
avg := sum/value;
Writeln('The mean average is ', avg:3:2);
Writeln;
Writeln('Press RETURN to end this program');
Readln();
END.

+++++++++++++++++++++++++++++

If you're interested in learning PASCAL, you should download this
PDF book:

"The Turbo Pascal Tutor" 2nd Edition (1986)
https://archive.org/details/bitsavers_borlandturersion2.01986_16488828
(about 16 Mb)

You might also download the manuals for the version of Turbo Pascal you
are using, specifically:

the Users Guide,
Language Guide, and
Programmers Guide

- which can also be found at www.archive.org/

David

---
Post by Chris Muyna
1. Write a program called Sum and Average to produce the sum of 1,2,3,...
to an upper bound (e.g 100). Also compute and display the average.
the sum is 5050
the average is 50.5
anyone can me a scrip about that question? PASCUL TURBO
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Continue reading on narkive:
Loading...