menu search
person

Write a program in C++, to find factorial of a given number using for loop.

thumb_up_alt 0 like thumb_down_alt 0 dislike
2 views

1 Answer

 
verified

#include <iostream>  

using namespace std;  

int main()  

{  

  int i,fact=1,number;    

  cout<<"Enter any positive Number: ";    

  cin>>number;    

  for(i=1;i<=number;i++)

  {    

      fact=fact*i;  //for 5! = 5*4*3*2*1  

  }    

  cout<<"Factorial of entered number" <<number<<" is: "<<fact<<endl;  

  return 0;  

}  


Output::
image

thumb_up_alt 0 like thumb_down_alt 0 dislike
...