This is a simple C++ Calculator.
It can get confused sometimes if there are too many digits but if you want to change
Code:
int b,c;
or any of the other int's to long, then it will work fine too.
Tell me if it doesn't work for you.
Code:
#include <iostream>
using namespace std;
int main()
{
int a;
cout<<"witch opperation would you like to do\n";
cout<<"for addition press 1\n";
cout<<"for subtraction press 2\n";
cout<<"for multiplication press 3\n";
cout<<"for division press 4\n";
cout<<"\n";
cin>> a;
cin.ignore();
if (a==3)
{
int b,c;
cout<<"what is the first number you would like to multiply? ";
cin>> b;
cin.ignore();
cout<<"what is the second? ";
cin>> c;
cout<<""<< b*c <<"";
cin.get();
cin.get();
}
if (a==1)
{
int d,e;
cout<<"what is the first number you would like to add? ";
cin>> d;
cin.ignore();
cout<<"what is the second? ";
cin>> e;
cout<<"" << d+e <<"";
cin.get();
cin.get();
}
if (a==2)
{
int f,g;
cout<<"what is the first number you would like to subtract? ";
cin>> f;
cin.ignore();
cout<<"what is the second? ";
cin>> g;
cin.ignore();
cout<<"" << f-g <<"";
cin.get();
cin.get();
}
if (a==4)
{
int h,i;
cout<<"what is the numerator? ";
cin>> h;
cin.ignore();
cout<<"what is the denomanator? ";
cin>> i;
cin.ignore();
cout<<"" << h/i <<"";
cin.get();
cin.get();
}
}
It can get confused sometimes if there are too many digits but if you want to change
Code:
int b,c;
or any of the other int's to long, then it will work fine too.
Tell me if it doesn't work for you.
Code:
#include <iostream>
using namespace std;
int main()
{
int a;
cout<<"witch opperation would you like to do\n";
cout<<"for addition press 1\n";
cout<<"for subtraction press 2\n";
cout<<"for multiplication press 3\n";
cout<<"for division press 4\n";
cout<<"\n";
cin>> a;
cin.ignore();
if (a==3)
{
int b,c;
cout<<"what is the first number you would like to multiply? ";
cin>> b;
cin.ignore();
cout<<"what is the second? ";
cin>> c;
cout<<""<< b*c <<"";
cin.get();
cin.get();
}
if (a==1)
{
int d,e;
cout<<"what is the first number you would like to add? ";
cin>> d;
cin.ignore();
cout<<"what is the second? ";
cin>> e;
cout<<"" << d+e <<"";
cin.get();
cin.get();
}
if (a==2)
{
int f,g;
cout<<"what is the first number you would like to subtract? ";
cin>> f;
cin.ignore();
cout<<"what is the second? ";
cin>> g;
cin.ignore();
cout<<"" << f-g <<"";
cin.get();
cin.get();
}
if (a==4)
{
int h,i;
cout<<"what is the numerator? ";
cin>> h;
cin.ignore();
cout<<"what is the denomanator? ";
cin>> i;
cin.ignore();
cout<<"" << h/i <<"";
cin.get();
cin.get();
}
}