Search This Blog

Monday, 21 December 2020

Arithematic ooprations using class

 

dnyaneshwarchakotkar.bogspot.com

#include <iostream>

using namespace std;


//define class

class operations

{

    //member variables

    public:

        int num1,num2;


    //member function or methods

    public:

       void add()

       {

           cout<<"enter two number for addition : ";

           cin>>num1>>num2;

           cout<<"addition = "<<num1+num2;

           cout<<"\n";

       }


        void sub()

       {

           cout<<"enter two number for subtraction : ";

           cin>>num1>>num2;

           cout<<"addition = "<<num1-num2;

           cout<<"\n";

       }


        void mul()

       {

           cout<<"enter two number for multiplication : ";

           cin>>num1>>num2;

           cout<<"addition = "<<num1*num2;

           cout<<"\n";

       }


        void div()

       {

           cout<<"enter two number for division : ";

           cin>>num1>>num2;

           cout<<"addition = "<<(float)num1/num2;

           cout<<"\n";

       }

};

 int main()

 {

     //creation of object

      operations op1;

      op1.add();

      op1.sub();

      op1.mul();

      op1.div();

      return 0;

 }






if you have more source code in simle way join this blog also do like and get the subsciption of tha blog on dnyaneshwarchakotkar.blolgspot.comm



also share the blog link to your friebnd for study,.....!!!!!


No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts