A C program to find factorial using a user defined function

#include<stdio.h>
int fact(int n)
{
 int z=1;
 for(; n>=1; n--)
    z = z * n;
 return(z);
}

void main()
{

 int num,f;
 printf("Enter any number : ");
 scanf("%d", &num);
 f = fact(num);
 printf("Factorial value of %d is %d",num,f);
 return 0;
}

Comments

Popular posts from this blog

Visti Cloud Service (VCS)

Being a DARK SKINNED is not a PROBLEM