mcqs bucket

  • MCQs Bucket | Program Write a program in C ++ That finds a Factorial of a given number.

    mcqsbucket

      Best guide for exams of all nature, Competitive exams and Interviews

Write a program in C ++ That finds a Factorial of a given number.

	 
                                 		

  #include < iostream >
  using namespace std;
   int main()
       {
           unsigned int n;
          unsigned long long factorial = 1;
          cout << "Enter a positive integer: ";
           cin >> n;
                for(int i = 1; i <=n; ++i)
                    {
                        factorial *= i;
                    }
                cout << "Factorial of " << n << " = " << factorial;
                 return 0;
             }