bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

prac_012.cpp (608B)


      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 using loop */
      8 
      9 #include <iostream>
     10 using namespace std;
     11 
     12 class fact {
     13     int inp, a = 1, i;
     14 
     15 public:
     16     void input();
     17     void calc();
     18     void output();
     19 };
     20 
     21 void fact::input() {
     22     cout << "enter the number :";
     23     cin >> inp;
     24 }
     25 
     26 void fact::calc() {
     27     for (i = 1; i <= inp; i++) {
     28         a = a * i;
     29     }
     30 }
     31 
     32 void fact::output() {
     33     cout << "factorial : " << a;
     34 }
     35 
     36 int main() {
     37     fact z;
     38     z.input();
     39     z.calc();
     40     z.output();
     41     return 0;
     42 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror