•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 391,560 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,742 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:
Views: 674 | Replies: 6
![]() |
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,809
Reputation:
Rep Power: 11
Solved Threads: 184
•
•
Join Date: Nov 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
program eight;
uses crt;
var
stop : integer;
posinteger : integer;
sum : integer;
begin
sum := 0;
writeln('Enter a positive integer, 0 to quit');
readln(stop);
while stop <> 0 do
begin
posinteger := stop mod 2;
readln;
if posinteger = 0
then
writeln('This number is even')
else
writeln('This number is odd');
readln;
clrscr;
writeln('Enter a positibe integer, 0 to quit');
readln(stop);
end;
end.done it!
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,809
Reputation:
Rep Power: 11
Solved Threads: 184
Brilliant.
I'm going to pick. The way your code looks is a tremendous help to understanding.
You'll notice I made a couple of minor changes. First, I told the user (who might not be you) what he is expected to do to continue when the program pauses. Also, you had defined a variable "sum" which didn't do anything. I made it do something.
Enjoy!
I'm going to pick. The way your code looks is a tremendous help to understanding.
Pascal Syntax (Toggle Plain Text)
program eight; uses crt; var stop : integer; posinteger : integer; sum : integer; begin sum := 0; writeln('Enter a positive integer, 0 to quit'); readln(stop); while stop <> 0 do begin posinteger := stop mod 2; readln; if posinteger = 0 then writeln('This number is even') else writeln('This number is odd'); sum := sum + stop; writeln( 'Press ENTER to continue' ); readln; clrscr; writeln('Enter a positive integer, 0 to quit'); readln(stop); end; writeln( 'The sum of all the numbers you entered is ', sum ); end.
Enjoy!
Last edited by Duoas : Nov 20th, 2007 at 4:52 pm.
•
•
Join Date: Jun 2006
Location: Blumenau, Brazil
Posts: 67
Reputation:
Rep Power: 3
Solved Threads: 4
•
•
•
•
Pascal Syntax (Toggle Plain Text)
program eight; uses crt; var stop : integer; posinteger : integer; sum : integer; begin sum := 0; writeln('Enter a positive integer, 0 to quit'); readln(stop); while stop <> 0 do begin posinteger := stop mod 2; readln; if posinteger = 0 then writeln('This number is even') else writeln('This number is odd'); sum := sum + stop; writeln( 'Press ENTER to continue' ); readln; clrscr; writeln('Enter a positive integer, 0 to quit'); readln(stop); end; writeln( 'The sum of all the numbers you entered is ', sum ); end.
bye
Last edited by Micheus : Nov 25th, 2007 at 1:27 am.
"It always has, at least, two ways to make one same thing. Exactly that they are certain and wrong"(Micheus)
Brazil - Blumenau
Brazil - Blumenau
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
Similar Threads
- Pascal : Access a file of 100 Quiz questions so 12 Random ones are displayed? (Pascal and Delphi)
- Pascal Programmes (Pascal and Delphi)
- C++ questions, How do they do it? (C++)
- Pascal Programming Language Help (Legacy and Other Languages)
- Dev Pascal help! (Pascal and Delphi)
- Pseudo-Pascal Question: Need Help!! (Pascal and Delphi)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Designing simple menu in Pascal
- Next Thread: Indy for Delphi 6



!
Linear Mode