Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: free implementation? factorial?
Hello,

up to now I did not succeed in installing TinyCobol.  But in OpenCobol,
your program does not seem to work, unfortunately:

I built the program using:

cobc -c factorial.cob
cobc -c -fmain factorial-test.cob
cobc -o factorial factorial.o factorial-test.o

obtaining warnings like:
In file included from /tmp/cobg6pZps.c:9:
/tmp/cobg6pZps.c.h:11: warning: pointer targets in initialization differ in 
signedness

Running the program I obtain:

> ./factorial
Enter a positive number: 0
Factorial(0000)= 000000000000000001
> ./factorial
Enter a positive number: 1
Factorial(0001)= 000000000000000000

I used the following programs (with indentation, because OpenCobol did not
understand it otherwise):


factorial.cob:

identification division.
program-id. factorial.
data division.
working-storage section.
1 m pic 9(4).
local-storage section.
1 n pic 9(4).
linkage section.
1 aNumber pic 9(4).
1 fact    pic 9(18).
procedure division using aNumber fact.
move aNumber to n
if n>0 then
compute m = n - 1
call "factorial" using by content m by reference fact
compute fact = n * fact
else
compute fact = 1
end-if
exit program

Report this thread to moderator Post Follow-up to this message
Old Post
Nicolas Neuss
01-10-06 11:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:22 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.