Make Factorial Function in C by R4R Team

Factorial:

-factorial of number is the multiplication of every integer number between 1 and that number.

Example-
factorial of 3 is 6(1*2*3)
factorial of 5 is 120(1*2*3*4*5)

Function:-A part of program which is uniquely identify and have different area.
-Here we make a function that are able to return the factorial of the given number.

program-

#include < stdio.h>
int Factorial(int n)
{
printf("Enter Number\n");
scanf("%d",&n);
ans=Factorial(n);
printf("Factorial is %d",ans);
}


output-

Enter Number
5
Factorial is 120

-In this program, we make a function named as 'Factorial(int n)', here 'n' is the argument which pass in the function for finding the factorial.
-We run the loop start from 1 to input number i.e. for(i=1;i< n=;i++)
-Multiply each value of i in loop ans store in 'fac' variable and at last it would return by the function.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!