Program in C to find factorial of number using while loop

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


#include <stdio.h>
#include <conio.h>
void main()
{
            int i=1,n,fact=1;
            clrscr();
            printf("enter a number");
            scanf("%d",&n);
            while(i<=n)
            {
                        fact=fact*i;
                        printf("%d",i);
                        i++;
            }
            printf("fact=%d",fact);
            getch();
}


Post a Comment