IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CAdvanced Functions : Recursive Factorial
<06.13>
#include <stdio.h> int factorial (int n) { int ans; if (n == 0) ans = 1; else ans = n * factorial(n - 1); return (ans); } int main (void) { int a, result; printf ("Enter an integer number: "); scanf ("%d", &a); /* calling the function */ result = factorial (a); /* printing the report */ printf ("The factorial of %d is %d.\n", a, result); return (0); }
Hergestellt in Deutschland / Made in Germany
Enter an integer number: 6 The factorial of 6 is 720.
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland