C++ Program to Find Factorial of a Number


Aim :- Write a C++ Program To Find Factorial of a Number.

C++ program to For Finding Factorial of a Number.
Factorial is Given By : Factorial = 1*2*3...*n
Factorial of Negative Number Cannot Be Find.
Factorial of 0 is 1.


C++ Program Code :


#include<stdio.h>
#include<iostream.h>
void main()
{
      int n,fact = 1;
      clrscr();

      cout << "\nC++ Program to Find Factorial of a Number.";
      cout << "\n\nEnter a Number : ";
      cin >> n;

      for(int i = 1; i <=n; ++i)
      {
            fact = fact * i;
      }

      cout << "Factorial of " << n << " : " << fact;

      getch();
}


Output :


Other Examples

Post a Comment

0 Comments