what would be the recursive implementation of the following c program:
int fact(int n)
{
if (n == 0) return (1);
else return(n*fact(n – 1));
}
shopnobhumi 0 Light Poster
Recommended Answers
Jump to Postwhat would be the recursive implementation of the following c program:
int fact(int n) { if (n == 0) return (1); else return(n*fact(n – 1)); }
That is recursive. You've defined
fact
--a function that calls itself.Did you mean "what would be the non-recursive implementation"?
…
Jump to Postwhat you wrote is a c++ code..but i need assembly code for this(i.e-MIPS)
Ah. It helps if you say what you want when you post a question.
Well,this code is already the recursive implementation of factorial,Since it calls itself in the last line.The other approach for factorial would be the …
All 8 Replies
gusano79 247 Posting Shark
shopnobhumi 0 Light Poster
Max.mx 0 Newbie Poster
shopnobhumi 0 Light Poster
gusano79 247 Posting Shark
marcel222 0 Newbie Poster
eng.ehsan07 0 Newbie Poster
eng.ehsan07 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.