Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help please.....

15 views
Skip to first unread message

Chris Muyna

unread,
Sep 24, 2019, 4:27:33 AM9/24/19
to
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

unread,
Sep 25, 2019, 9:28:41 AM9/25/19
to

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

---
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

0 new messages