Question
Here is a little program that calls a function Add
, once
with integer arguments, and once with string arguments. Implement the
functions Add
so that if the arguments are integers their
sum is returned, and if the arguments are strings the integer value
of their concatenation is returned. For example
Add(27,99)
returns 126, but Add("27","99")
returns 2799.
#include <iostream.h>
#include ANYTHING ELSE YOU NEED
const int STRING_LENGTH = 100;
typedef char string[STRING_LENGTH];
FUNCTION DECLARATION GO HERE
//----------------------------------------------------------------------------
int main(void) {
cout << "The sum of 27 and 99 is " << Add(27,99) << endl;
cout << "The concatenation of 27 and 99 is " << Add("27","99") << endl;
return(0);
}
//----------------------------------------------------------------------------
FUNCTION IMPLEMENTATIONS GO HERE
//----------------------------------------------------------------------------
AND HERE
//----------------------------------------------------------------------------
Answer