0% found this document useful (0 votes)
13 views2 pages

C Program to Calculate Factorial

Uploaded by

shehnass2002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

C Program to Calculate Factorial

Uploaded by

shehnass2002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include<stdio.

h>

int fact(int);

int main()

int num, res;

//Ask user for the input and store it in num

printf("\nEnter any integer number:");

scanf("%d",&num);

//Calling our user defined function

res =fact(num);

//Displaying factorial of input number

printf("\nfactorial of %d is: %d",num, res);

return 0;

int fact(int n)

int res;

//Factorial of 0 is 1

if(n==0)

res=1;

else
//Function calling itself: recursion

return(n*fact(n-1));

return res;

You might also like