8.Factorial using for loop
#include<stdio.h>
int main(){
int num,factorial=1;
printf("Enter a number :");
scanf("%d",&num);
for(int i=1; i<=num; i++)
{
factorial=factorial*i;
}
printf("\nThe factorial of %d is :%d",num,factorial);
return 0;
}
Comments
Post a Comment