SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
Procedural Abstraction And Functions That Return A Value
Exercise:
Self-test Exercises
Question:8 | ISBN:9780321531346 | Edition: 7

Question

Write a function declaration and a function definition for a function that

takes one argument of type double. The function returns the character

value 'P' if its argument is positive and returns 'N' if its argument is zero

or negative.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

The function declaration is:

char positive_test(double number);

 

//Returns 'P' if number is positive.

//Returns 'N' if number is negative or zero.

The function definition is:

char positive_test(double number)
{
    if (number > 0)
        return 'P';
    else
        return 'N';
}

 

0 0

Discussions

Post the discussion to improve the above solution.