comp.lang.ada
 help / color / mirror / Atom feed
From: rgelb@csulb.edu (Robert Gelb)
Subject: Help with Translation, please!
Date: 1996/02/26
Date: 1996-02-26T00:00:00+00:00	[thread overview]
Message-ID: <4gt2ri$3jq@garuda.csulb.edu> (raw)

I am having a hell of a time translating a little recursive factorial 
program from C to Ada.  Could some please help me.  Below is the C code 
that needs to be translated to ADA


#include <stdio.h>
int factorial(int);

int main() {
	long f;
	int number;

	printf("\nPlease enter factorial number:");
	scanf("%d", &number);	/*get the factorial number*/
	f = factorial(number);  /*invoke factorial function*/
	printf ("Result: %ld", f);
	return 0;
}

int factorial(int n) {
	int ReturnValue;
	if (n > 1)
		ReturnValue = n * factorial(n-1);
	else
		ReturnValue = 1;

	return ReturnValue;
}






             reply	other threads:[~1996-02-26  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-02-26  0:00 Robert Gelb [this message]
1996-02-27  0:00 ` Help with Translation, please! Pascal OBRY
     [not found] <4gvta2$531@ds8.scri.fsu.edu>
     [not found] ` <4h2gu9$hp6@watnews1.watson.ibm.com>
1996-03-15  0:00   ` Robert I. Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox