home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,583 of 2,978   
   Dr J R Stockton to All   
   Re: Turbo Pascal question   
   23 Dec 07 16:36:53   
   
   XPost: comp.lang.pascal.ansi-iso   
   From: jrs@merlyn.demon.co.uk   
      
   In comp.lang.pascal.ansi-iso message ,   
   Sat, 22 Dec 2007 20:52:31, john  posted:   
   >Dr J R Stockton wrote:   
   >> In comp.lang.pascal.ansi-iso message ,   
   >> Sat, 22 Dec 2007 01:15:05, john  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.  ?@merlyn.demon.co.uk   Turnpike v6.05   MIME.   
    Web   - FAQish topics, acronyms, & links.   
    For news:borland.*, use their server newsgroups.borland.com ; but first read   
    Guidelines  ff. with care.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca