fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class Factorial
  5. {
  6. int n,p=1,i;
  7. public:
  8. Factorial()
  9. {
  10. cout<<"Enter a number: ";
  11. cin>>n;
  12. for(i=2;i<=n;i++)
  13. p*=i;
  14.  
  15. }
  16. void display()
  17. {
  18. cout<<"\nFactorial is: "<<p;
  19. }
  20. };
  21.  
  22.  
  23. int main()
  24. {
  25. Factorial obj;
  26. obj.display();
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Enter a number: 
Factorial is: 0