Write a C program using while loop to find factorial of a positive number.

#include<stdio.h>
main()
{
    int n,i=1,f=1;
    printf("\nEnter a number=");
    scanf("%d",&n);
    while(i<=n)
    {
        f=f*i;
        i++;
    }
    printf("\nfactorial of %d is %d",n,f);       
}

No comments:

Post a Comment