prac_006.cpp (615B)
1 /* 2 * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 22 Jun 2026 3 * Repo: https://github.com/notamitgamer/bsc 4 * License: MIT 5 */ 6 7 /* factorial */ 8 9 #include <iostream> 10 using namespace std; 11 12 class fact { 13 int inp, a, i; 14 15 public: 16 void input(); 17 void calc(); 18 void diplay(); 19 }; 20 21 void fact::input() { 22 cout << "enter the number :"; 23 cin >> inp; 24 a = inp; 25 } 26 27 void fact::calc() { 28 for (i = 1; i <= inp - 1; i++) { 29 a = a * i; 30 } 31 } 32 33 void fact::diplay() { 34 cout << "Factorial " << a << "."; 35 } 36 37 int main() { 38 fact z; 39 z.input(); 40 z.calc(); 41 z.diplay(); 42 return 0; 43 }