C++ Program To Find Factorial

This program is used to find factorial of n numbers.


2.Get the input from user for variable n (ie) an integer number
3.Initialize fact as 1
4.You will need a for loop to find factorial of given number
5.In for loop set i as 1 then compare if i is lesser than or equal to zero
6.If step-5 is true declare fact as fact * i and if step-5 is false stop the program
7.Increment i value by 1


# include <iostream.h>
# include <conio.h>
void main ()
          int n, fact = 1;
          cout << "Enter Value For N:";
          cin >> n;
          for (int i = 1; i <= n; i + +)
                    fact = fact * i;
           cout << "The Factorial Of" << n << "Is:" << fact;
           getch ();
C++ Program To Find Factorial C++ Program To Find Factorial Reviewed by Manish Jain on February 22, 2014 Rating: 5
Powered by Blogger.