Computer Science, asked by butterflysly6, 3 months ago

Write A program in C++ create a class name calculator
*Data member* :
int a,b,c
*Member function* :
void addition ( )
void subtraction ( )
void multiplication ( )
void division ( )

Write main method and create an object for calling the above functions.

Answers

Answered by DeepakUgalePatil
3

Answer:

#include<iostream>

using namespace std;

class calculator {

public:

void addition(int n1, int n2)

{

cout << "Addition = "<<n1+n2;

}

void subtraction(int n1, int n2)

{

cout << "subtraction = "<< n1-n2;

}

void multiplication(int n1, int n2)

{

cout << "multiplication = "<< n1*n2;

}

void division(int n1, int n2)

{

cout << "division = "<< n1/n2;

}

};

int main()

{

int a, b,c;

calculator ar;

cout << "Enter two Numbers :: ";

cin >> a>> b;

ar.addition(a, b);

ar.subtraction(a, b);

ar.multiplication(a, b);

ar.division(a, b);

return 0;

}

Explanation:

please vote my answer

Similar questions