What do you mean it won't work? Also, what compiler? I used Dev-C++ 4.9.8.0 and it worked fine. But, you should add some line breaks so you can tell the answers apart (unless there's a reason for that). Also, what is the point of answer? You can just use:
Code:
return number operation number;
//Like
return A * B;
Here's some code that works fine on Dev-C++:
Code:
#include <iostream>
int Add( int A, int B )
{
return A + B;
}
int Subtract( int C, int D )
{
return C - D;
}
int Multiply( int E, int F )
{
return E * F;
}
int Divide( int G, int H )
{
return G / H;
}
int main ()
{
int Number1, Number2;
std::cout << "Enter the numbers: ";
std::cin >> Number1 >> Number2;
std::cout << Add( Number1, Number2 ) << std::endl;
std::cout << Subtract( Number1, Number2 ) << std::endl;
std::cout << Multiply( Number1, Number2 ) << std::endl;
std::cout << Divide( Number1, Number2 ) << std::endl;
std::cin.get();
std::cin.get();
return 0;
}
Note you can still use using namespace std; system( "PAUSE" ); and answer (although it doesn't need to be global). Also, you can, in the std::cin statement, using the comma instead of an additional >>. You should also probably put a prompt, as it makes more sense.
- SirCrono6