Pages

Sunday, 21 June 2015

Factorial using loop

Factorial of a given number using Loop

Coding:

#include<stdio.h>
int main()
{
int n,i,p;
printf("PLease enter the number:");
scanf("%d",&n);
p=1;
for(i=1;i<=n;i++)
p=p*i;
printf("Result:%d!=%d",n,p);
return 0;
}

Output:
PLease enter the number:5
Result:5!=120