Advertisement
Farhana_Zaman

Untitled

May 20th, 2023
1,163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. class ADD
  6. {
  7.    public:
  8.       ADD(int i = 0)
  9.       {
  10.          total = i;
  11.       }
  12.       void Addnumber(int num)
  13.       {
  14.          total = total + num;
  15.       }
  16.       int Gettotal()
  17.       {
  18.          return total;
  19.       }
  20.  
  21.    private:
  22.       int total;
  23. };
  24.  
  25. int main()
  26. {
  27.    ADD add_number;
  28.    int a, b, c;
  29.  
  30.    cout<<"Enter three numbers: ";
  31.    cin>>a>>b>>c;
  32.  
  33.    add_number.Addnumber(a);
  34.    add_number.Addnumber(b);
  35.    add_number.Addnumber(c);
  36.  
  37.    cout<<"\nTotal = "<<add_number.Gettotal();
  38.    cout<<endl;
  39.  
  40.    return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement