Advertisement

Factorial, using loop.


#include<conio.h>
#include<stdio.h>

void main()
{   clrscr();
    int i,n,sum;
    printf("limit=");
    scanf("%d",&n);
    sum=1;
    i=1;
    while(i<=n)
    {  sum=sum*i;
       i++;
       }
       printf("%d",sum);
       getch();
       }

No comments:

Post a Comment

Please comment bellow. Share your knowledge