C program to find factorial of a number

Lists of programs for finding factorial: C program to  find factorial of a number using recursion, c program to  find factorial of a number using functions,  c program to  find factorial of a number using for loop, c program to  find factorial of a number using while loop, c program to  find factorial of number using do while. c program to  find factorial of number using call by reference.

The factorial of a number n is
n x (n-1) x (n-2)… x 1
example factorial of number 5 is : 5 x 4 x 3 x 2 x 1 =120 and
factorial of number 3 is : 3 x 2 x 1=6

C program for factorial of a number using recursion, functions, for loop, while loop
write a c program for factorial of a number using recursion, functions, for loop, while loop

C program to find factorial of a number using recursion

C program for factorial of a number using recursion

#include<stdio.h>
void main()
{
int n;
printf(“OUTPUT:  C program to find factorial of a number using recursion\n”);
printf(“Enter the number :”);
scanf (“%d \n”, &n);
printf(” factorial is:”);
findfactorial(n);
}
//recursive function for factorial
int findfactorial(int x )
{
int fact=0;
if (x=1)
return 1
else
fact=x * findfactorial( x-1 );
return fact;
}

OUTPUT: C program to find factorial of a number using recursion
OUTPUT: C program to find factorial of a number using recursion

C program to find factorial of a number using functions

C program to find factorial of a number using functions

#include<stdio.h>
void main()
{
int n;
printf(“OUTPUT:  C program to calculate factorial of a number using functions \n \n”);
printf(“Enter the number :”);
scanf (“%d \n”, &n);
printf(“factorial is:”);
findfactorial(n);
}

int findfactorial(int x )
{
int fact=1, i;
for(i=2;i<=x;i++)
{
fact=fact*i;
}
return(fact);
}

OUTPUT: C program to find factorial of a number using functions
OUTPUT: write a c program for factorial of a number using functions

C program calculate factorial of a number using for loop

C program to find factorial of a number using for loop

#include<stdio.h>
void main()
{
int N , f=1, i;
printf(” OUTPUT:  C program to calculate factorial of a given number using for loop \n \n”);
printf(“Enter the number : “);
scanf (“%d \n”, &c);
for(i=2;i<=N;i++)
{
f=f*i;
}
printf(“factorial is %d”, f);
}

OUTPUT: C program to find factorial of a given number using for loop
OUTPUT: write a C program to find factorial of a given number using for loop

C program for factorial of a number using while loop

C program for factorial of a number using while loop

#include<stdio.h>
void main()
{
int num, count , fact;
printf(“OUTPUT:  c program to calculate factorial of a given number using while loop \n\n”);
printf(“Enter the number :”);
scanf (“%d \n”, &num);
count =1;
fact=1;
while ( num > 1)
{
count++ ;
fact=fact*count;
num= num-1;
}
printf(“factorial is:%d”, fact);
}

OUTPUT: C program to find factorial of a given number using while loop
OUTPUT: C program for factorial of a number using while loop

C program to find factorial of number using do while loop

C program for factorial of a number using while loop

#include<stdio.h>
void main()
{
int num, count , fact;
printf(“OUTPUT:  c program to calculate factorial of a given number using while loop \n\n”);
printf(“Enter the number :”);
scanf (“%d \n”, &num);
fact=1;count=1
DO
{
fact=fact*count;
count++ ;
}
while ( i<=num)
printf(“factorial is:%d”, fact);
}

C program to find factorial of number using call by reference

C program to find factorial of number using call by reference

#include<stdio.h>
void main()
{
int n;
printf(“OUTPUT: C program to find factorial of number using call by reference \n \n”);
printf(“Enter the number :”);
scanf (“%d \n”, &n);
printf(“factorial is:”);
findfactorial(&n);
}

int findfactorial(int *x )
{
int fact=1, i;
for(i=2;i<=*x;i++)
{
fact=fact*i;
}
return(fact);
}

Other programs:

Static variable scope
Register variable scope
External variable scope
Automatic variable scope
amicable number
Prime number
Perfect number
Palindrome number
Strong number
Find Factorial 
Biggest Number
Average of n numbers
decimal number to octal
decimal number to hexadecimal
convert decimal number to binary
simple interest
compound interest
Add sparce matrices
Add matrices
 file copying
Palindrome string
Reverse string
String length
Replace characters in string
substring or not using arrays
First occurrence of character in string
Last occurrence of character in string
Convert to uppercase
Convert to lowercase
Concatenate strings 
Compare strings
Generate Employee payslips
Count students scoring marks>50%
convert weight into grams

 

Leave a Reply

Your email address will not be published. Required fields are marked *