From: Nicolas Neuss on
Hello,

I am teaching a CS course ("Programming and Software Techniques") at the
university of Heidelberg. This course uses C++, but I want to give my
students also a feeling for other languages. To this end, I have reserved
a little bit of time (5-10 minutes of each session) for telling them a
little about other languages (history, some important features) and showing
them the factorial function written in this language.

Now, since COBOL is an important language, I want to include it in this
way, too. I was able to find some information about COBOL in Wikipedia
which should suffice for the short overview, but I have not succeeded in
finding a free implementation for COBOL. Is there such a thing (maybe a
demo version)? Furthermore, as much as I understand the factorial function
is already available in modern COBOL implementations, so it is difficult to
find a suitable program (at least, what I found with Google is either
untested or looks suboptimal). If factorial would not be available, how
would it look like in modern COBOL?

Thanks, Nicolas.
From: charles hottel on
go to google groups and enter "comp.lang.cobol" then do a search on
"factorial hottel" you will find a factorial program from the COBOL
programmers guide that uses the LOCAL-STORAGE SECTION.


"Nicolas Neuss" <firstname.lastname(a)iwr.uni-heidelberg.de> wrote in message
news:87mzi5tn9y.fsf(a)ortler.iwr.uni-heidelberg.de...
> Hello,
>
> I am teaching a CS course ("Programming and Software Techniques") at the
> university of Heidelberg. This course uses C++, but I want to give my
> students also a feeling for other languages. To this end, I have reserved
> a little bit of time (5-10 minutes of each session) for telling them a
> little about other languages (history, some important features) and
> showing
> them the factorial function written in this language.
>
> Now, since COBOL is an important language, I want to include it in this
> way, too. I was able to find some information about COBOL in Wikipedia
> which should suffice for the short overview, but I have not succeeded in
> finding a free implementation for COBOL. Is there such a thing (maybe a
> demo version)? Furthermore, as much as I understand the factorial
> function
> is already available in modern COBOL implementations, so it is difficult
> to
> find a suitable program (at least, what I found with Google is either
> untested or looks suboptimal). If factorial would not be available, how
> would it look like in modern COBOL?
>
> Thanks, Nicolas.


From: Louis Krupp on
Nicolas Neuss wrote:
> I am teaching a CS course ("Programming and Software Techniques") at the
> university of Heidelberg. This course uses C++, but I want to give my
> students also a feeling for other languages. To this end, I have reserved
> a little bit of time (5-10 minutes of each session) for telling them a
> little about other languages (history, some important features) and showing
> them the factorial function written in this language.
>
> Now, since COBOL is an important language, I want to include it in this
> way, too. I was able to find some information about COBOL in Wikipedia
> which should suffice for the short overview, but I have not succeeded in
> finding a free implementation for COBOL. Is there such a thing (maybe a
> demo version)? Furthermore, as much as I understand the factorial function
> is already available in modern COBOL implementations, so it is difficult to
> find a suitable program (at least, what I found with Google is either
> untested or looks suboptimal). If factorial would not be available, how
> would it look like in modern COBOL?

I've never used TinyCobol, but it might be worth a try. I think an
iterative factorial implementation might be easier to follow than a
recursive routine. This would look something like:

move 1 to factorial.
perform varying t from 2 to number
multiply factorial by t
end-perform.

Louis
From: Nicolas Neuss on
"charles hottel" <jghottel(a)yahoo.com> writes:

> go to google groups and enter "comp.lang.cobol" then do a search on
> "factorial hottel" you will find a factorial program from the COBOL
> programmers guide that uses the LOCAL-STORAGE SECTION.

You mean

<http://groups.google.com/group/comp.lang.cobol/msg/fc907f4b09daefdf>
?

I had found this one already, but had somehow hoped that a nicer version
would be possible, e.g. something like in

<http://groups.google.com/group/comp.lang.cobol/msg/fae713b0615c1445>

Thank you,

Nicolas.
From: Oliver Wong on

"Louis Krupp" <lkrupp(a)pssw.nospam.com.invalid> wrote in message
news:11s5hqph3vd97e6(a)corp.supernews.com...
> Nicolas Neuss wrote:
>> I am teaching a CS course ("Programming and Software Techniques") at the
>> university of Heidelberg. This course uses C++, but I want to give my
>> students also a feeling for other languages. To this end, I have
>> reserved
>> a little bit of time (5-10 minutes of each session) for telling them a
>> little about other languages (history, some important features) and
>> showing
>> them the factorial function written in this language.
>>
[snip]
>
> I've never used TinyCobol, but it might be worth a try. I think an
> iterative factorial implementation might be easier to follow than a
> recursive routine. This would look something like:
>
> move 1 to factorial.
> perform varying t from 2 to number
> multiply factorial by t
> end-perform.
>

I'm not exactly a COBOL expert, but from what I understand, COBOL85
doesn't support recursive calls anyway; at least, not in the way that a Java
(or C++) programmer would expect recursion to work.

- Oliver


 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10
Prev: Data Representation in COBOL
Next: xml acucobol