| | |
Could you tell me what is (are) wrong of my program?
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Feb 2009
Posts: 93
Reputation:
Solved Threads: 0
Dear Sir,
Could you tell me what is wrong of my program?
The question is: write a progrm that totals up a list of exactly 100 numbers and outputs that total to the screen, also show the average of the 100 numbers.
My program:
Could you tell me what is wrong of my program?
The question is: write a progrm that totals up a list of exactly 100 numbers and outputs that total to the screen, also show the average of the 100 numbers.
My program:
Pascal and Delphi Syntax (Toggle Plain Text)
program Project2; {$APPTYPE CONSOLE} uses SysUtils; var total, number, count: integer; average: real; begin total:=0; for count:=1 to 100 do begin readln(number); total:=total+number; end; writeln(total); average:=total/100; writeln(average:6:2); end.
Last edited by Tekmaven; Jun 3rd, 2009 at 4:04 pm. Reason: Code Tags
•
•
Join Date: Jun 2009
Posts: 4
Reputation:
Solved Threads: 1
•
•
•
•
Dear Sir,
Could you tell me what is wrong of my program?
The question is: write a progrm that totals up a list of exactly 100 numbers and outputs that total to the screen, also show the average of the 100 numbers.
My program:
Pascal and Delphi Syntax (Toggle Plain Text)
program Project2; {$APPTYPE CONSOLE} uses SysUtils; var total, number, count: integer; average: real; begin total:=0; for count:=1 to 100 do begin readln(number); total:=total+number; end; writeln(total); average:=total/100; writeln(average:6:2); end.
You may need to store average to a double (float), or maybe a variant.
Not sure which pascal you are using.
Hi turbomen.
Your program is working well....where is the problem?
If you want to get the average result as decimals then
write here:
Write('The average is :',average:6:0);
got it?
Your program is working well....where is the problem?
If you want to get the average result as decimals then
write here:
Write('The average is :',average:6:0);
got it?
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
![]() |
Similar Threads
- Not sure what is wrong in this program (Java)
- Can anyone figure out what is wrong in my program? (C++)
- not sure what is wrong with this program....pleaseeee helppp confused: (Java)
- What is wrong with my program? (Assembly)
- Can't see the program execute (C++)
- Can any1 tell me whatz wrong in this program...this does not show the output!!! (C++)
- Can someone tell me what wrong with this program it doesn't run (C++)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Delphi Prism
- Next Thread: pascal keyboard numbers
| Thread Tools | Search this Thread |





