Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Fella

Pascal problem

This topic is 5680 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

program blabla; var c : char; begin while c <> ''&'' do begin read(c); if (c >= ''a'') and (c <= ''z'') then writeln(c) else writeln(ord(c)); end; end. For example input is letter ''b''. I get this output: b 13 10 Why are 10 and 13 in the output?????

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
it''s been awhile since i took Pascal. great language though

if (c >= ''a'') and (c <= ''z'') then writeln(c)<----
else writeln(ord(c));

shouldn''t writeln(c) have a semicolon? (referring to the arrow)

Share this post


Link to post
Share on other sites
#13+#10 is the return carrage (new line) sequence. It goes back to line printers (which could/can be used in place of the screen). One character tells it to move the cursor down one line, the other tells it to go to the beginning of the line (move left).

Share this post


Link to post
Share on other sites
Incidentally, you can use sets. They''re lovely.

if (c in [''a''..''z'']) then
  stuff;

This doesn''t relate to your issue (which is the carriage return/line feed thing as Michalson said).

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster

if (c >= ''a'') and (c <= ''z'') then writeln(c)<----
else writeln(ord(c));

shouldn''t writeln(c) have a semicolon? (referring to the arrow)


Just like to point out in case it helps anyone, as far as I know you dont use a semicolon before an else.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!