Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following C function computes the factorial of an integer: int fact (int n )

ID: 3616458 • Letter: T

Question

The following C function computes the factorial of an integer:

int fact (int n )
{ if (n<=1) return 1;
else return n * fact (n-1) ;
}

Could you please rewrite this function into imperative style (i.eusing variables and eliminating recursion).
I would like to have the main method also so I could test.
thanks,
Adam
PS : I do rate life saver

Explanation / Answer

please rate - thanks #include #include int fact(int); int main() {     int n;     printf("Enter the number: negative to exit");     scanf("%d",&n);     while(n>=0)        {           printf("n!=%d",fact(n));        printf(" Enter number:negative to exit ");       scanf("%d",&n);         }     getch();     return 0; } int fact(int n) {int i,nf=1; for(i=2;i