Question: Problem Develop an analogous C++ program which plays with only the single-parameter math library functions described in Figure 6.2 (uploaded pic). Build a table of
Problem
Develop an analogous C++ program which plays with only the single-parameter math library functions described in Figure 6.2 (uploaded pic). Build a table of functions that your program drives through with a for-statement to process a single double-precision real.
Hint #1 Since youre using only the single-parameter math library functions, do not make an entry in your table for either of the 2-parameter functions fmod() and pow()).
Hint #2 Your FUNCTION struct can be a little simpler than the one FunWithFunctionPointers.cpp used because there is no need for the returnsBool field. Why? Because each function-pointer in your table points-to a function that returns a double-precision real result that has only 1 interpretation. For the same reason, the body of your for-statement is also simplerno need for an if/else-statement to select between the different interpretations!
Please post source code with your reply so I can easily copy & paste it into my compiler. Also, please post a screenshot with it compiled. Thank you,


// FunWithFunctionPointers.cpp
#include
#include
#include
#include
#include
using namespace std;
struct FUNCTION
{
bool returnsBool; // else returns char;
string description;
int (*function)(int c);
};
FUNCTION functions[] =
{
{ true," isdigit",isdigit },
{ true," isalpha",isalpha },
{ true," isalnum",isalnum },
{ true,"isxdigit",isxdigit },
{ true," islower",islower },
{ true," isupper",isupper },
{ false," tolower",tolower },
{ false," toupper",toupper },
{ true," isspace",isspace },
{ true," iscntrl",iscntrl },
{ true," ispunct",ispunct }
};
//--------------------------------------------------------
int main()
//--------------------------------------------------------
{
char c;
cout
while ( cin >> c )
{
for (int i = 0; i
{
int r = functions[i].function((int) c);
if ( functions[i].returnsBool )
cout
else
cout
}
cout
}
system("PAUSE");
return( 0 );
}
Example Function Description ceil(9.2) is 10.0 ceil(-9.8) is -9.0 cos (0.0) is 1.0 exp (1.0) is 2.718282 exp(2.0) is 7.389056 ceil(x) rounds x to the smallest integer not less than x cos (x) trigonometric cosine of x (x in radians) exp(x) exponential functione Fig. 6.2 | Math library functions. (Part I of 2.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
