Program

How to create a c++ application like calculator... Please Help Me !!!
Last edited on
command line or GUI ?
#include <iostream>
#include <cstdlib>
using namespace std;
int c ;

void add(int x, int y)
{
int a;
a = x + y;
cout <<"Answer is -> " << a << endl;
}

void negative(int x, int y)
{
int a;
a = x - y;
cout <<"Answer is -> " << a << endl;
}

void multiple(int x, int y)
{
int a;
a = x * y;
cout <<"Answer is -> " << a << endl;
}

void divide(int x, int y)
{
int a;
a = x / y;
cout <<"Answer is -> " << a << endl;
}


int main()
{
cout << "Welcome to the (add/minus/multiple/divide) simple calculator!" << endl;
cout << "Enter 1 if u want to add something.."<< endl;
cout << "Enter 2 if u want to minus something.."<< endl;
cout << "Enter 3 if u want to multiple something.."<< endl;
cout << "Enter 4 if u want to divide something.."<< endl;
cin >> c ;
while ( c > 0)
{
if ( c == 1 )
{
system("cls");
int x, y;
cout << "Insert your first number and second number!"<< endl;
cin >> x >> y;
add(x,y);
system("PAUSE");
}
else if ( c == 2 )
{
system("cls");
int x, y;
cout << "Insert your first number and second number!"<< endl;
cin >> x >> y;
negative(x,y);
system("PAUSE");

}
else if ( c == 3 )
{
system("cls");
int x, y;
cout << "Insert your first number and second number!"<< endl;
cin >> x >> y;
multiple(x,y);
system("PAUSE");

}
else if ( c == 4 )
{
system("cls");
int x, y;
cout << "Insert your first number and second number!"<< endl;
cin >> x >> y;
divide(x,y);
system("PAUSE");

}
else
{
system("cls");
cout << "Incorrect input pls type again!" << endl;
}

}
return 0;

}

// this is a simple calculator only can use in addition/minus/multiple/divide! Sry for the roughly code i am fresh too...
closed account (48T7M4Gy)
What's wrong with it because it appears to run?
What application can create a c++
closed account (48T7M4Gy)
I assume you mean something like Visual Studio
I mean the output is actually a application
@JJ2828

Only addition are running but the minus multiplication and division are not running
closed account (48T7M4Gy)
You will get an .exe file produced if all goes well using VStudio
Topic archived. No new replies allowed.