<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'inverting a number' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'inverting a number' posted on the 'Pascal' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2008 Programmers Heaven</copyright>
    <pubDate>Fri, 04 Jul 2008 19:42:16 -0700</pubDate>
    <lastBuildDate>Fri, 04 Jul 2008 19:42:16 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>inverting a number</title>
      <link>http://www.programmersheaven.com/mb/pasprog/370652/370652/ReadMessage.aspx</link>
      <description>&lt;div class="BoardMessageAreaPrinterFriendly"&gt;
&lt;h2 class="BoardMessageSubjectPrinterFriendly"&gt;inverting a number&lt;/h2&gt;
&lt;div class="BoardMessageInfoPrinterFriendly"&gt;Posted by  on 27 Mar 2008 at 10:52 AM&lt;/div&gt;
&lt;div class="BoardMessageBodyPrinterFriendly"&gt;need a hand with my pascal assignment... pls? i need to write a program that reverses the input number 'n'. i am asked to formulate an equation to come up with the answer. example input/output dialogue:&lt;br /&gt;
enter a number: 2546&lt;br /&gt;
reversed number: 6452&lt;br /&gt;
&lt;br /&gt;
the program should be simple.. no function or procedure... looping statements only (incrementations and decrementations)... i've tried using for... downto statement but it doesnt show results... please help me.. i'm stuck! your help would be very much appreciated.. thanks...&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</description>
      <pubDate>Thu, 27 Mar 2008 10:52:08 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: inverting a number</title>
      <link>http://www.programmersheaven.com/mb/pasprog/370652/370662/ReadMessage.aspx#370662</link>
      <description>&lt;div class="BoardMessageAreaPrinterFriendly"&gt;
&lt;h2 class="BoardMessageSubjectPrinterFriendly"&gt;Re: inverting a number&lt;/h2&gt;
&lt;div class="BoardMessageInfoPrinterFriendly"&gt;Posted by  on 27 Mar 2008 at 9:10 PM&lt;/div&gt;
&lt;div class="BoardMessageBodyPrinterFriendly"&gt;: need a hand with my pascal assignment... pls? i need to write a &lt;br /&gt;
: program that reverses the input number 'n'. i am asked to formulate &lt;br /&gt;
: an equation to come up with the answer. example input/output &lt;br /&gt;
: dialogue:&lt;br /&gt;
: enter a number: 2546&lt;br /&gt;
: reversed number: 6452&lt;br /&gt;
&lt;br /&gt;
Take the starting number and divide it by ten (2546 / 10 = 254 ).&lt;br /&gt;
Subtract the resulting number times ten from the original and this will give you the first digit. (2546 - (254 * 10) = 6)&lt;br /&gt;
Take the output (initially zero) and multiply it by ten, then add the digit from above.&lt;br /&gt;
(0 x 10 = 0 + 6 = 6)&lt;br /&gt;
Repeat this again (and again) until the starting number is zero and it would look like so:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Pass 2) 254 / 10 = 25
        254 - (25 * 10) = 4
        6 x 10 = 60 + 4 = 64
Pass 3) 25 / 10 = 2
        25 - (2 * 10) = 5
        64 x 10 = 640 + 5 = 645
Pass 4) 2 / 10 = 0
        2 - (0 * 10) = 2
        645 x 10 = 6450 + 2 = 6452
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
There are many ways, but hopefully this is basic enough to follow and uses only basic mulitplication &amp;amp; division. It could also be done faster and easier with MOD operations or converting it to a string, reversing the string and displaying the output.&lt;br /&gt;
&lt;br /&gt;
Phat Nat&lt;/div&gt;&lt;/div&gt;</description>
      <pubDate>Thu, 27 Mar 2008 21:10:32 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: inverting a number</title>
      <link>http://www.programmersheaven.com/mb/pasprog/370652/370680/ReadMessage.aspx#370680</link>
      <description>&lt;div class="BoardMessageAreaPrinterFriendly"&gt;
&lt;h2 class="BoardMessageSubjectPrinterFriendly"&gt;Re: inverting a number&lt;/h2&gt;
&lt;div class="BoardMessageInfoPrinterFriendly"&gt;Posted by  on 28 Mar 2008 at 12:25 PM&lt;/div&gt;
&lt;div class="BoardMessageBodyPrinterFriendly"&gt;: need a hand with my pascal assignment... pls? i need to write a &lt;br /&gt;
: program that reverses the input number 'n'. i am asked to formulate &lt;br /&gt;
: an equation to come up with the answer. example input/output &lt;br /&gt;
: dialogue:&lt;br /&gt;
: enter a number: 2546&lt;br /&gt;
: reversed number: 6452&lt;br /&gt;
: &lt;br /&gt;
: the program should be simple.. no function or procedure... looping &lt;br /&gt;
: statements only (incrementations and decrementations)... i've tried &lt;br /&gt;
: using for... downto statement but it doesnt show results... please &lt;br /&gt;
: help me.. i'm stuck! your help would be very much appreciated.. &lt;br /&gt;
: thanks...&lt;br /&gt;
: &lt;br /&gt;
My approach would be to read in the number, convert it to a string, reverse the string and then write out the number.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
begin
      ReadLn (n) ;  { program will crash here if the operator does
                      not enter a valid number }
      Str (n:0, sin) ;
      sout := '' ;
      for i := length(sin) downto 1 do
            sout := sout + sin[i] ;
      Val (s, n, code) ;
      WriteLn (n)
end.
&lt;/pre&gt;&lt;br /&gt;
I may have the order of the parameters wrong for Str and Val, and hopefully the use of Str and Val does not violate the requirement ".. no function or procedure..." since you do not have to write them.  A simpler approach would be to input and output the number as a string and not have to use Str and Val, but then any string could  be reversed, not just a number.  I'm assuming the assignment requires the input to be a number (integer or real).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</description>
      <pubDate>Fri, 28 Mar 2008 12:25:14 -0700</pubDate>
      <category>Pascal</category>
    </item>
  </channel>
</rss>