### Write a C program to find the factorial of a given integer using non-recursive function

In this article, we will write a C program to find the factorial of a given integer using a non-recursive function.

# ALGORITHM:

Step 1: Start

Step 3: Call fact(n) goto step 6

Step 4: Store result in “f”

Step 5: Print “f” goto step 10

Step 6: Begin //sub program Initialize f ← 1

Step 7: for i is 1 to n by step 2

Step 8: Calculate f = f*i

Step 9: return “f” End

Step 10: Stop

# Write a C program to find the factorial of a given integer using a non-recursive function

``````#include <stdio.h>
#include <conio.h>

int fact(int);
void main()
{
int n, i, f;
clrscr();
printf("ENTER A VALUE FOR n:\n");
scanf("%d", &n);
f = fact(n);
printf("THE FACTORIAL OF A GIVEN NO IS -> %d", f);
getch();
}
int fact(int n)
{
int i, f = 1;
for (i = 1; i <= n; i++)
f = f * i;
return (f);
}
``````

INPUT:

``````ENTER A VALUE FOR n
5
``````

OUTPUT:

``THE FACTORIAL OF A GIVEN NUMBER IS -> 120``

# Free Spring Boot Tutorial - 5 Hours Full Course

Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course