calc_fact - printf("n factorial =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* calc_fact.c * Program demonstrating the use of a function to calculate n!. */ #include <stdio.h> int fact(int m); /* function prototype */ int main() { int n, nfact; printf("Integer n? "); scanf("%d", &n); nfact = fact(n); /* function call */
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf(&quot;n factorial = %d\n&quot;, nfact); return 0; } int fact(int m) { /* function to calculate m factorial */ int i, result; result = 1; for (i = 1; i &lt;= m; i++) result *= i; return result; }...
View Full Document

Ask a homework question - tutors are online