prac_006.cpp (479B)
1 /* factorial */ 2 3 #include <iostream> 4 using namespace std; 5 6 class fact { 7 int inp, a, i; 8 9 public: 10 void input(); 11 void calc(); 12 void diplay(); 13 }; 14 15 void fact::input() { 16 cout << "enter the number :"; 17 cin >> inp; 18 a = inp; 19 } 20 21 void fact::calc() { 22 for (i = 1; i <= inp - 1; i++) { 23 a = a * i; 24 } 25 } 26 27 void fact::diplay() { 28 cout << "Factorial " << a << "."; 29 } 30 31 int main() { 32 fact z; 33 z.input(); 34 z.calc(); 35 z.diplay(); 36 return 0; 37 }