SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
c++ program for factorial using class
c++ program for factorial using class
Output:
enter the value of n:
5
the factorial of 5 is 120
Implementation:
#include
using namespace std; class factorial { int fact=1,n; public: void findfact(); void displayres(); }; void factorial::findfact() { cout<<"enter the value of n:"<
>n; int i=2; while(i<=n) { fact*=i; i++; } } void factorial::displayres() { cout<<"the factorial of "<
PREVIOUS
NEXT
HOME