Sponsored Links

Sunday, December 15, 2013

Program Calculate Factorial of a Number

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 x 4 x 3 x 2 x 1 = 120
Note: The value of 0! is 1.

find factorial of a number C++ Program
/*
Write a C++ Program to input a positive number
Calculate and Display Factorial of this number
by For Loop.


For Free C++ Programming Techniques (Example Programs), visit
Www.EasyCppProgramming.Blogspot.Com

and For Good Notes
Visit   Www.ForFreeEducation.Blogspot.Com
*/
#include<iostream.h>

#include<conio.h>

void main()
{

  clrscr();

  int number, counter;
  long int factorial;

  cout<<"\n Enter the Number = ";

  cin>>number;

  factorial = 1;
  for (counter = 1; counter <= number; counter++)
           factorial = factorial * counter;

  cout<<"\n\n ----------- Results ------------";

  cout<<"\n\n The Factorial of the number "<<number<<"\n is "<<factorial;

  getch();

}
Program Factorial