Sunday, 8 January 2017

C Program To Calculate Factorial Of A Given Number

Problem :- Write A C Program To Calculate Factorial Of A Given Number .

What Is Factorial :- In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,

5!=5*4*3*2*1=120.

The value of 0! is 1, according to the convention for an empty product*

The factorial operation is encountered in many areas of mathematics, notably in combinatorics, algebra, and mathematical analysis. Its most basic occurrence is the fact that there are n! ways to arrange n distinct objects into a sequence (i.e., permutations of the set of objects). This fact was known at least as early as the 12th century, to Indian scholars .
source :- Wikipedia

See Also :- C++ Program To Calculate Factorial Of A Given Number 

Solution :-

Method 1 :- Factorial Using For Loop

#include<stdio.h>

int main()
{
/*Program By Ghanendra Yadav
    Visit http://www.programmingwithbasics.com/
    */
 
unsigned long long int fact=1;
  int i,num;
 
printf("Enter The Number. You Want Factorial  :");
  scanf("%d",&num);
 
for(i=1;i<=num;i++)
    {
        fact=fact*i;
    }
    
printf("\nFactorial is = %llu\n",fact);
    return 0;

}



Output :-

C Program To Calculate Factorial Of A Given Number

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment