🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.misc
Article #140

Re: New to pascal, need help w/ program

#140
From: Bob Schor
Date: Fri, 08 Jan 1999 00:00
53 lines
2883 bytes
Joshua Roth wrote:

> I'm currently taking a Pascal course as a requirement for my major,
> and my
> instructor is probably the worst instructor I've ever had. I now have
> homework due in less then a week, and I have know clue how to do it.
> Can
> anyone help me out? Here is the problem:
>
> Make the unrealistic assumption that your computer has maxint equal to
> 18,
> and write a program to read in two numbers of 10 or fewer digits and
> output
> their sum. The two numbers are stored in arrays of the following type:
>
>               type
>                  Number = array[0...9] of integer;
>
> Each digit of a number is stored in one indexed variable of it's
> array. The
> numbers are to be read as character values, one digit at a time, using
> a
> variable of type char. Each digit is converted into a number and
> stored in
> an indexed variable of an array. If the number is less than 10 digits
> long,
> then leading zeros should be added to the array.
> an addition procedure is then called to calculate the sum and stored
> it in a
> third array. If the sum would be more than 10 digits long, the two
> numbers
> read in and their sum are output.

     One hint.  Pretend you are in Second Grade.  When you learned your
"Plus
tables", the highest number you ever dealt with was 18.  How did you add
two
10-digit numbers?  [As the mathematicians would say, these two problems
are
isomorphic ...].

Bob Schor
Pascal Enthusiast

P.S. -- Why not actually TRY to do this problem?  Think about an
algorithm, and give
it a try.  When dealing with a BIG problem ("Add two 10-digit numbers"),
first try to
make it a SMALL problem ("Add two one-digit numbers"), then think about
how to
make it bigger (if I can add one-digit numbers, what "extra" do I have
to do to add
two-digit numbers?).
Technical Details
Message-ID: <36965618.AF796A3A@vms.cis.pitt.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <nNfl2.402$kt3.5337@typhoon-sf.pbi.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1006de,96d55c5bdf0b8d1a
X-Google-Attributes: gid1006de,public
X-Google-Thread: 10261c,96d55c5bdf0b8d1a
X-Google-Attributes: gid10261c,public
X-Google-Thread: fd1d1,96d55c5bdf0b8d1a
X-Google-Attributes: gidfd1d1,public
X-Google-Thread: 102601,96d55c5bdf0b8d1a
X-Google-Attributes: gid102601,public
X-Google-Thread: 16176c,96d55c5bdf0b8d1a
X-Google-Attributes: gid16176c,public
From: Bob Schor <bschor@vms.cis.pitt.edu>
Subject: Re: New to pascal, need help w/ program
Date: 1999/01/08
Message-ID: <36965618.AF796A3A@vms.cis.pitt.edu>
X-Deja-AN: 430280648
Content-Transfer-Encoding: 7bit
References: <nNfl2.402$kt3.5337@typhoon-sf.pbi.net>
X-Priority: 3 (Normal)
Content-Type: text/plain; charset=us-ascii
Organization: Department of Otolaryngology, University of Pittsburgh
Mime-Version: 1.0
Reply-To: bschor@vms.cis.pitt.edu
Newsgroups: comp.lang.pascal.misc,csugrad.programming.pascal,ctdl.lang.pascal,de.comp.lang.pascal,de.comp.lang.pascal.misc