Questions: Factorial Program in C. To find Factorial of a number using C Program. C program to find factorial of a given number. Factorial of a number in C. Program to find factorial using recursion.
Factorial of a number
Factorial of a number is represented by the symbol “!” and
for any real positive number “n” it is written as “n!” where n! = 1 * 2 * 3 * ….
* n. Here we will learn program for finding factorial of a number using C.
Required Knowledge and Software
C Programming Operator
C Programming Variable
and C Programming expression
C Programming Data Type
C if statement
C Programming for
loop
C Programming software Dev C++ /Turbo C++
Check: Flowchart for Factorial of a number
Logic to find factorial of a number in c programming
Algorithm for finding factorial of a number with detailed explanation were discussed below:
- Input a number and store it in a variable say "num".
- Initialize another variable that will store factorial say "fact".
- Run loop from 1 to num.
- Multiply the current loop counter value.
Check: Area of triangle ; Flowchart for area of triangle
Program to find factorial of a number
#include<stdio.h>
int find_factorial(int);
main()
{
int num, fact;
//Ask user for the input and store it in num
printf("\nEnter any integer number:");
scanf("%d",&num);
//Calling our user defined function
fact =find_factorial(num);
//Displaying factorial of input number
printf("\nfactorial of %d is: %d",num, fact);
return 0;
}
find_factorial(n)
{
//Factorial of 0 is 1
if(n==0)
return(1);
//Function calling itself: recursion
return(n*find_factorial(n-1));
}
0 Comments