9.Factorial using while loop

 #include<stdio.h>


int main(){
    int n,i=1;
    int factorial=1;
    printf("enter a number :\n");
    scanf("%d",&n);
    while(i<=n)
    {
    factorial=factorial*i;
    i++;
    }
    printf("The fctorial of %d is :%d",n,factorial);
    return 0;
}

Comments