Tuesday, March 5, 2024

5.Input a number from user and then print the factorial of the number :—

5.Input a number from user and then print the factorial of the number :—


#include<stdio.h>

int main()

{

    int i,j,n;

    printf("enter a number ");

    scanf("%d",&n);

    j=1;

    for(i=1;i<=n;i++)

    {

        j=j*i;

    }    

    printf("factorial of %d=%d\n",n,j);

    return 0;

}


No comments:

Post a Comment