Calculator using c++ Programming


 #include<iostream>
using namespace std;
void add();
void subtract();
void divide();
void multiply();
int main()
{
	int a;
	cout << "Enter 1 for add:" << endl;
	cout << "Enter 2 for subtract:" << endl;
	cout << "enter 3 for divide:" << endl;
	cout << "Enter 4 for multiply:" << endl;
	cin >> a;
	if (a == 1)
	{
		add();
	}
	if (a == 2)
	{
		subtract();
	}
	if (a == 3)
	{
		divide();
	}
	if (a == 4)
	{
		multiply();
	}

	
	
	getchar();
	getchar();
	return 0;
}
void add()
{
	int a, b,c;
	cout << "Enter the 1st value:";
	cin >> a;
	cout << "Enter the 2nd value:";
	cin >> b;
	c = a + b;
	cout << "Sum is " << c << endl;

}
void subtract()
{
	int a, b, c;
	cout << "Enter the 1st value:";
	cin >> a;
	cout << "Enter the 2nd value:";
	cin >> b;
	c = a - b;
	cout << "Subtraction is:"<<c << endl;
}
void divide()
{
	int a, b, c;
	cout << "Enter the 1st value:";
	cin >> a;
	cout << "Enter the 2nd value:";
	cin >> b;
	c = a / b;
	cout << " Division is : " << c << endl;
}
void multiply()
{
	int a, b,c;
	cout << "Enter the 1st value:";
	cin >> a;
	cout << "Enter the 2nd value:";
	cin >> b;
	c = a*b;
	cout << "Multiplication is:" << c << endl;
}       

Comments

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........