This is a basic calculator I made in C++. I am learning C++ on my own.

``````#include <iostream>
using namespace std;

{
float c;
c=a+b;
return (c);
}

float Subtract (float &a,float &b)
{
float c;
c=a-b;
return (c);
}

float Divide (float &a,float &b)
{
float c;
c=a/b;
return (c);
}

float Multiply (float &a,float &b)
{
float c;
c=a*b;
return (c);
}

int main ()
{
for (int g=1;g!=0;g++)
{
int a, b;
cout << "Calculator Made By Matthew Sedam.\n";
cout << "2 - Subtract.\n";
cout << "3 - Multiply.\n";
cout << "4 - Divide.\n";
cin >> a;
if (a!=1,2,3,4)
{
return 0;
}
if (a==1)
{
float b,c,d;
cout << "Enter the First Number.\n";
cin >> b;
cout << "Enter the Second Number.\n";
cin >> c;
cout << b << " + " << c << "= " << d << ".\n";
}
if (a==2)
{
float b,c,d;
cout << "Enter the First Number.\n";
cin >> b;
cout << "Enter the Second Number.\n";
cin >> c;
d = Subtract(b,c);
cout << b << " - " << c << "= " << d << ".\n";
}
if (a==3)
{
float b,c,d;
cout << "Enter the First Number.\n";
cin >> b;
cout << "Enter the Second Number.\n";
cin >> c;
d = Multiply(b,c);
cout << b << " X " << c << "= " << d << ".\n";
}
if (a==4)
{
float b,c,d;
cout << "Enter the First Number.\n";
cin >> b;
cout << "Enter the Second Number.\n";
cin >> c;
d = Divide(b,c);
cout << b << " / " << c << "= " << d << ".\n";
}
}
return 0;
}``````

And how well does it work?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.