1 May 2010

C Program to Find Factorial of a Number

Hello friends! In this post, I want to share with you my codes of a program titled “Factorial of a number”, that I programmed using C programming language as part of my B.Tech course “Computer Programming and Problem Solving Lab”.


The algorithm of this program is simple. It will go on multiplying all natural numbers starting from 1 to the number whose factorial is to be found. The multiplication process is handled by a “For Loop”.

Output Window of Factorial program coded using C


The source code for this simple program is given below:


//c program to find the factorial of entered number
#include <stdio.h>
#include <conio.h>
int main()
{
    int i,number,factorial=1;
    printf("***********PROGRAM TO FIND FACTORIAL OF THE NUMBER*****************\nEnter the Number:\t");
    scanf("%d",&number);
    for(i=1;i<=number;i++)
    {
                          factorial=factorial*i;
    }
    printf("*******************************************************************\n");
    printf("Factorial of %d is %d",number,factorial);
    getch();
}  
If you have any query or doubt, you can comment below. Thanks for visiting this blog.
Related Post :


0 comments:

Post a Comment

If you liked this blog then Join me at:
Facebook
Twitter
RSS