Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Ansi -iso > Re: Turbo Pasca...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 16 of 16 Topic 199 of 215
Post > Topic >>

Re: Turbo Pascal question

by Dr J R Stockton <jrs@[EMAIL PROTECTED] > Dec 23, 2007 at 04:36 PM

In comp.lang.pascal.ansi-iso message <fkjmdf$v23$1@[EMAIL PROTECTED]
>,
Sat, 22 Dec 2007 20:52:31, john <john@[EMAIL PROTECTED]
> posted:
>Dr J R Stockton wrote:
>> In comp.lang.pascal.ansi-iso message
<fkhhdq$kpc$1@[EMAIL PROTECTED]
>,
>> Sat, 22 Dec 2007 01:15:05, john <john@[EMAIL PROTECTED]
> posted:
>>> More precisely, I want to do a program that provides and stores the
>>> reverse of a number. For example:
>>>
>>> input: 12345
>>>
>>> result: 54321
>>  var S : string ;
>> Str(N, S) ;
>>  T := 0 ;
>> for J := 1 to S.length do T := T*10 + Ord(S[J]) - 48 ;
>>  or
>>  T = "" ;
>> for J := 1 to S.length do T = T + S[J] ;
>>  Untested; adjustment may be needed.
>>
>>> Is there any way I can do casting in Turbo Pascal 7.1
>>  No such version.  To cast in TP/BP, read the manual.
>>  I have no idea whether that code will work in on-topic Pascal; for
>>TP &
>> BP you should be using comp.lang.pascal.borland; see below; read FAQ.
>
>
>I want to use integral variables, not strings. That is, it is a
>calculation issue not only a display issue.

Then you should use

var S, T, X : longint ;
begin
T := 54321 ;
S := 0 ;
while T>0 do begin S := S * 10 + T mod 10 ; T := T div 10 end ;
writeln(S) end.


If that's coursework, perhaps you should consider a different career.

XP, FU set

-- 
 (c) John Stockton, Surrey, UK.  ?@[EMAIL PROTECTED]
   Turnpike v6.05  
MIME.
 Web  <URL:http://www.merlyn.demon.co.uk/>
- FAQish topics, acronyms, &
links.
 For news:borland.*, use their server newsgroups.borland.com ; but first
read
 Guidelines <URL:http://www.borland.com/newsgroups/guide.html>
ff. with
care.
 




 16 Posts in Topic:
Turbo Pascal question
john <john@[EMAIL PROT  2007-12-20 21:09:11 
Re: Turbo Pascal question
Richard Heathfield <rj  2007-12-20 19:29:28 
Re: Turbo Pascal question
Dr J R Stockton <jrs@[  2007-12-21 13:44:12 
Re: Turbo Pascal question
john <john@[EMAIL PROT  2007-12-22 01:15:05 
Re: Turbo Pascal question
john <john@[EMAIL PROT  2007-12-22 01:38:43 
Re: Turbo Pascal question
Richard Heathfield <rj  2007-12-22 00:58:29 
Re: Turbo Pascal question
john <john@[EMAIL PROT  2007-12-22 13:18:49 
Re: Turbo Pascal question
Richard Heathfield <rj  2007-12-22 11:43:12 
Re: Turbo Pascal question
"Jochen" <jo  2007-12-22 22:42:57 
Re: Turbo Pascal question
john <john@[EMAIL PROT  2007-12-23 01:33:35 
Re: Turbo Pascal question
"Jochen" <jo  2007-12-23 05:56:25 
Re: Turbo Pascal question
scott moore <nospam@[E  2007-12-23 10:33:04 
Re: Turbo Pascal question
john <john@[EMAIL PROT  2007-12-24 00:59:51 
Re: Turbo Pascal question
Dr J R Stockton <jrs@[  2007-12-22 17:51:06 
Re: Turbo Pascal question
john <john@[EMAIL PROT  2007-12-22 20:52:31 
Re: Turbo Pascal question
Dr J R Stockton <jrs@[  2007-12-23 16:36:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 23 15:45:04 CDT 2008.