## C program to find factorial of a number using function – atozprogram

C program to find factorial of a number using function – atozprogram

If you are beginner in C program . Then I suggest you to visit following topics , So which will make you understand this programming easily and also increase your programming skill.

Today we will learn ” C program to find factorial of a number using function” . We have already solve this problem but using Loop  in our previous post . But today we will solve using function but programming is different but they give same output . If you have no knowledge to find factorial using  then :
here;

Let’s come to the topic , before starting program let me define ‘Function’.  ” Function  is a group of statement that together perform a specific task.  Want to learn more about function

Function in C – Concept of function, function definition, function prototype:

Without delay let’s go to program to find factorial using function.

C Program Find Factorial Of A Number Using Function:
`````` #include<stdio.h>
#include<conio.h>
int fun(int);
main()
{
int n,x;
printf("n Enter any number:");
scanf("%d",&n);
x=fun(n);
printf("n The factorial of %d is %d.",n,x);
getch();
}
int fun(int n)
{
int fact=1;
while(n!=0)
{
fact=fact*n;
n=n-1;
}
return(fact);
}
``````

Explanation:

This is one easy program to find factorial of a number using function . We have define function ” int fun(int)” in header . Then just ask user to enter any number and print output . In function we will print output first and perform calculation in below and call that define function to store value .

Output:

In my program I have find factorial of 5 and you can see output too . If you have any problem in program then you can comment below or visit my social page and ask your question . I will be available 24 hrs for your help and you can follow me too .
Similar Post; 