S
Stefan Ram
Write a function
double f( int c, double x );
that will return either the sine or the logarithm of its
second argument depending on whether it was called with a
first argument 0 or 1, respectively (that is, 0 for sine and
1 for logarithm), but do not use any control statement (such
as »if« or »while«) nor any operator with conditional
evaluation (such as ?:, &&, ||).
When the first argument is 0, the function must call
(directly or indirectly) »sin« (math.h), but must not call
(directly or indirectly) »log« (math.h). When the first
argument is 1, the function must call »log«, but must not
call »sin«.
The definition of additional helper functions is allowed
under the same restrictions as given above.
(I believe that I could write such a function when the
definition of additional helper functions is allowed, but I
do not have an idea how to do it without additional functions.)
double f( int c, double x );
that will return either the sine or the logarithm of its
second argument depending on whether it was called with a
first argument 0 or 1, respectively (that is, 0 for sine and
1 for logarithm), but do not use any control statement (such
as »if« or »while«) nor any operator with conditional
evaluation (such as ?:, &&, ||).
When the first argument is 0, the function must call
(directly or indirectly) »sin« (math.h), but must not call
(directly or indirectly) »log« (math.h). When the first
argument is 1, the function must call »log«, but must not
call »sin«.
The definition of additional helper functions is allowed
under the same restrictions as given above.
(I believe that I could write such a function when the
definition of additional helper functions is allowed, but I
do not have an idea how to do it without additional functions.)