//Program
to find factorial of a number
#include <stdio.h>
#include <conio.h>
void main()
{
int i, n, f = 1;//Initialize the value of f as 1
clrscr();
printf("Enter any positive integer
value\n");
scanf("%d", &n);
for (i = 1; i <= n; i++)
//for loop using initialization 1, test condition <=n and increment by 1 each time
//for loop using initialization 1, test condition <=n and increment by 1 each time
f = f * i;
printf("Factorial of %d = %d\n", n,
f);
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.