Write a c++ program to Add two value using constructor . The constructor will have two parameters (only for intake 41 section 4)

Question

Write a c++ program to Add two value using constructor . The constructor will have two parameters (only for intake 41 section 4)

in progress 1
Ask me anything 3 years 31 Answers 515 views 1

Answers ( 31 )

  1. Ques- Create a function called sroot that return the square root of  its given argument overload sroot in three ways show the output in main function.

     

    I am getting  errors  and don’t know whats the problem !   Please help me out !

     

    Here is the code —
    #include<iostream>
    #include<cmath>
    using  namespace std;
    class myclass{

    int sroot (int n);
    long sroot (long m);
    double sroot (double r);

    int sroot (int n);
    {
    return n=pow(n,0.5);
    }
    class myclass :: int sroot (int n)
    {
    n=pow(n,0.5);
    return n;

    }
    long sroot (long m);
    {
    return m=pow(m,0.5);
    }
    class myclass :: long sroot (long m)
    {
    m=pow(m,0.5);
    return m;

    }
    double sroot (double r);
    {
    return r=pow(r,0.5);
    }
    class myclass :: double sroot (double n)
    {
    r=pow(r,0.5);
    return r;

    }
    int main()
    {
    myclass obj;
    obj.sroot(9);
    obj.sroot(100);
    obj.sroot(121);
    return 0;
    }


    };

    •  

       

       

      Check This out Ashraful…………………………………………

      #include<iostream>
      #include<cmath>
      using namespace std;
      class myclass{

      public:
      int sroot(int n);
      float sroot(float n);
      double sroot(double n);

      };
      int myclass::sroot( int n)
      {
      int m;
      m = pow(n,0.5);
      return m;
      }
      float myclass::sroot(float n)
      {
      int a;
      a = pow(n,0.5);
      return a;
      }
      double myclass::sroot(double n)
      {
      int b;
      b=pow(n,0.5);
      return b;
      }
      int main()
      {
      myclass obj;
      cout<<obj.sroot(16)<<endl;
      cout<<obj.sroot(16.16)<<endl;
      cout<<obj.sroot(16.16)<<endl;
      return 0;
      }

  2. Name:Md. Emon Ali

    Id:154

    #include<iostream>
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<<endl;
    cin >> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  3. Name: Arman Hossain

    Id: 18192103156

    Intake:41… Sec-04

    class myClass {
    int c;
    public:

    myClass() {
    cout << “The Sum is :” ;
    }

    myClass(int a, int b) {
    c = a + b;
    }

    void show() {
    cout << c;
    }
    };

    int main() {

    int a, b;

    cout << “Enter Two Numbers :”;
    cin >> a>>b;

    myClass t;
    myClass obj(a, b);
    obj.show();

    return 0;
    }

  4. Name: Arman Hossain

    Id: 18192103156

    Intake:41… Sec-04

     

    #include<iostream>
    using namespace std;
    class myClass {
    int c;
    public:

    myClass() {
    cout << “The Sum is :” ;
    }

    myClass(int a, int b) {
    c = a + b;
    }

    void show() {
    cout << c;
    }
    };

    int main() {

    int a, b;

    cout << “Enter Two Numbers :”;
    cin >> a>>b;

    myClass t;
    myClass obj(a, b);
    obj.show();

    return 0;
    }

  5. Name: Rakibul Hasan Shafin

    ID: 18192103165

    Intake: 41

    Section: 04

    #include<iostream>
    using namespace std;

    class myClass {
    int c;
    public:

    myClass() {
    cout << “The Sum is :” ;
    }

    myClass(int a, int b) {
    c = a + b;
    }

    void show() {
    cout << c;
    }
    };

    int main() {

    int a, b;

    cout << “Enter Two Numbers :”;
    cin >> a>>b;

    myClass t;
    myClass obj(a, b);
    obj.show();

    return 0;
    }

  6. Name: Tamanna Tasnim

    ID: 142

     

    #include <iostream>
    using namespace std;

    class construct
    {
    public:
    int a, b;

    construct()
    {
    a;
    b;
    }
    };

    int main()
    {

    construct X;
    cin >> X.a >> X.b;
    cout << “Sum = ” << X.a + X.b << endl;

    return 1;
    }

  7. Md Muntasir Mamun

    Id:18192103179

    Intake:41 , sec:4

    #include<iostream>
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<<endl;
    cin >> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  8. Arup Raton Chowdhury

    id : 18192103155

    #include<iostream>
    using namespace std;

    class myclass {
    int a;
    int b;
    int z;
    public :
    myclass();
    void show();
    };
    myclass :: myclass ()
    {
    cout << ” Enter numbers : “;
    cin>> a >> b;
    z=a+b;
    }
    void myclass :: show ()
    {
    cout << z;
    }

    int main() {

    myclass obj;
    obj.show();

    return 0;
    }

  9. ID:18192103149

    Intake:41; Section:4

    #include<iostream>
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<<endl;
    cin >> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  10. ID: 18192103153;

    Intake:41;

    Section:4;

    #include <iostream>
    using namespace std;

    class myClass {
    int c;
    public:

    myClass() {
    cout << “The Sum is :”;
    }

    myClass(int a, int b) {
    c = a + b;
    }

    void show() {
    cout << c;
    }
    };

    int main() {

    int a, b;

    cout << “Enter Two Numbers :”;
    cin >> a>>b;

    myClass t;
    myClass obj(a, b);
    obj.show();

    return 0;
    }

  11. ID: 18192103153;

    Intake:41;

    Section:4;

    #include <iostream>
    using namespace std;

    class myClass {
    int z;
    public:

    myClass() {
    cout << “The Sum is : “;
    }

    myClass(int x, int y) {
    z = x + y;
    }

    void show() {
    cout << z;
    }
    };

    int main() {

    int x, y;

    cout << “Enter Two Numbers : “;
    cin >> x>> y;

    myClass t;
    myClass obj(x, y);
    obj.show();

    return 0;
    }

  12. Name: Moinul islam

    id: 18192103180

     

    #include<iostream>
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<<endl;
    cin >> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  13. Name : Masudul Islam Asif

    ID NO : 18192103147

    Intake: 41

    Sec      : 4

     

    #include<iostream>
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<<endl;
    cin >> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  14. Name: Tahmid Hossain Rasel

    ID:18192103168

     
    #include<iostream>
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout << "Enter Two Numbers :";
    cin >> a >> b;
    }

    void sum() {
    c = a + b;
    }

    void display() {
    cout << "nSum is :" << c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.display();

    return 0;
    }

  15. MD Ashraful Hossain Hridoy
    ID-18192103137

    #include<iostream>
    using namespace std;
    class myclass {
    int a,b,c;

    public :
    myclass();
    void show();
    };
    myclass :: myclass ()
    {
    cout << ” Enter numbers : “;
    cin>> a >> b;
    c=a+b;
    }
    void myclass :: show ()
    {
    cout << c;
    }
    int main() {
    myclass obj;
    obj.show();
    return 0;
    }

  16. Name: Mosraful Habib

    ID: 172

     

     

    #include<iostream>
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<<endl;
    cin >> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  17. Nigar sultana Era

    Id:18192103175

     

     

     

    class myClass {
    int c;
    public:

    myClass() {
    cout << “The Sum is :” ;
    }

    myClass(int a, int b) {
    c = a + b;
    }

    void show() {
    cout << c;
    }
    };

    int main() {

    int a, b;

    cout << “Enter Two Numbers :”;
    cin >> a>>b;

    myClass t;
    myClass obj(a, b);
    obj.show();

    return 0;
    }

  18. Name:Tabassum Mehrin Prova

    ID:177

    #include<iostream>

    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<<endl;
    cin >> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  19. Name:Shamima Akter Shimu Id:18192103144

    class myClass {
    int c;
    public:

    myClass() {
    cout << “The Sum is :” ;
    }

    myClass(int a, int b) {
    c = a + b;
    }

    void show() {
    cout << c;
    }
    };

    int main() {

    int a, b;

    cout << “Enter Two Numbers :”;
    cin >> a>>b;

    myClass t;
    myClass obj(a, b);
    obj.show();

    return 0;
    }

    1.  Name Asfack uddin nabil

      Id-173

      Sec 4

      #include<iostream>
      using namespace std;

      class myclass {
      int a;
      int b;
      int z;
      public :
      myclass();
      void show();
      };
      myclass :: myclass ()
      {
      cout << ” Enter numbers : “;
      cin>> a >> b;
      z=a+b;
      }
      void myclass :: show ()
      {
      cout << z;
      }

      int main() {

      myclass obj;
      obj.show();

      return 0;
      }

  20. Id -150

    #include<iostream>
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<<endl;
    cin >> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  21. Sorry it a private answer.

  22. Name: Rumman

    ID: 18192103138

    Intake: 41

    Section: 04

    #include<iostream>
    using namespace std;

    class myClass {
    int c;
    public:

    myClass() {
    cout << “The Sum is :” ;
    }

    myClass(int a, int b) {
    c = a + b;
    }

    void show() {
    cout << c;
    }
    };

    int main() {

    int a, b;

    cout << “Enter Two Numbers :”;
    cin >> a>>b;

    myClass t;
    myClass obj(a, b);
    obj.show();

    return 0;
    }

  23. Name:Sanjara

    Id:18192103166

    #include<iostream>
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<<endl;
    cin >> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  24. NAME: Bushrat Jahan

    ID: 18192103160

    SECTION: 04

    #include<bits/stdc++.h>
    using namespace std;
    class myclass{
    int a,b;
    public:

    myclass(int x, int y)
    {
    a=x;
    b=y;
    }
    int func()
    {
    return a+b;
    }
    };
    int main()
    {
    myclass obj(4,5);
    cout<<obj.func()<<endl;
    }

  25. D.K.Shah Alam
    iD.18192103176

    #include
    using namespace std;

    class myclass{
    int x;
    public:
    myclass(int a, int b)
    {
    x=a+b;
    }
    getx()
    {
    return x;
    }
    };

    int main ()
    {
    myclass obj(10,20);
    cout<<obj.getx();

    return 0;}

  26. Name: Rois Uddin Khan EMON
    Intake: 41
    Sec: 4
    ID:18192103153
    #include
    #include
    using namespace std;
    class sum{
    public:
    sum(int a, int b){
    int c = a + b;
    cout<<c<<endl;
    }
    };
    int main(){
    sum obj(10, 12);
    getch();
    return 0;
    }

  27. Name: MD Tayeb
    Intake: 41
    Section: 4
    ID: 18192103164

    #include
    using namespace std;

    class construct
    {
    public:
    int a, b;

    construct()
    {
    a;
    b;
    }
    };

    int main()
    {

    construct X;
    cin >> X.a >> X.b;
    cout << “Sum = ” << X.a + X.b << endl;

    return 1;
    }

  28. #include
    using namespace std;

    class Add {
    int a, b, c;
    public:

    Add() {
    cout <<“Enter Two Numbers :”<> a >> b;
    }

    int sum() {
    c = a + b;
    }

    int result() {
    cout <<“The Sum is: “<< c;
    }
    };

    int main() {

    Add obj;
    obj.sum();
    obj.result();

    return 0;
    }

  29. shaminur rahman
    id:158
    #include
    using namespace std;

    class construct
    {
    public:
    int a, b;

    construct()
    {
    a;
    b;
    }
    };

    int main()
    {

    construct X;
    cin >> X.a >> X.b;
    cout << “Sum = ” << X.a + X.b << endl;

    return 1;
    }

Leave an answer