1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yarga [219]
3 years ago
5

Write the definition of a function isPositive, that receives an integer parameter and returns true if the parameter is positive,

and false otherwise. So, if the parameter's value is 7 or 803 or 141 the function returns true. But if the parameter's value is -22 or -57, or 0, the function returns false.
Mathematics
1 answer:
Svetach [21]3 years ago
8 0

Answer:

BEGIN def function isPositive(int parameter)

//test for positivity

if parameter > 0

RETURN true

else

RETURN  false

END def function isPositive

Step-by-step explanation:

A number is a positive integer if it is a whole number and exists between 0 and positive infinity e. g 1, 90000, 42434234 e.t.c. It is a negative integer if it is a whole number and exists between negative infinity and 0(0 may be inclusive). e.g 0, -34342, -6984.

As shown on the first line, to define a function, we begin by writing the name of the function - "isPositive" in this case - followed by a pair of parenthesis which contains the parameter(s) on which the function will act on. In this case, the parameter is an integer - positive or negative.

Line 2 shows a comment describing what happens on the next four lines. i.e  checking whether or not the parameter's value is positive

Then, we write an if-else statement to check whether or not the parameter's value is a positive integer. If the parameter's value is greater than 0, the parameter's value is thus a positive integer then the function will return true. This is shown on lines 3 and 4. Otherwise, the parameter's value is a negative integer, thus the function returns a false as shown on lines 5 and 6.  

The last line in the expression shows the end of the function's definition.

Hope it helps.

You might be interested in
What is the sum of all of the perfect squares between
Nonamiya [84]

Answer:

(-138) is the answer.

Step-by-step explanation:

Perfect square numbers between 15 and 25 inclusive are 16 and 25.

Sum of perfect square numbers 16 and 25 = 16 + 25 = 41

Sum of the remaining numbers between 15 and 25 inclusive means sum of the numbers from 17 to 24 plus 15.

Since sum of an arithmetic progression is defined by the expression

S_{n}=\frac{n}{2}[2a+(n-1)d]

Where n = number of terms

a = first term of the sequence

d = common difference

S_{8}=\frac{8}{2} [2\times 17+(8-1)\times 1]

   = 4(34 + 7)

   = 164

Sum of 15 + S_{8} = 15 + 164 = 179

Now the difference between 41 and sum of perfect squares between 15 and 25 inclusive = 41-179

= -138

Therefore, answer is (-138).

7 0
3 years ago
a fabric store sells pieces of material for $5 each Ali bought two white pieces and 8 blue pieces she also bought a pack of butt
Murrr4er [49]
The term (2 + 8) is described as the total amount of pieces of fabric. It makes it easier to put this term this way so you wouldn't have to do (8 x 5) + (2 x 5) and do the distributive property.

8 0
3 years ago
Read 2 more answers
A sports store has 468 golf balls. They will be put into boxes that hold 18 balls each. What is the minimum number of boxes need
Alona [7]
468/18 = 26

Therefore they need at least 26 boxes to hold all the golf balls.

Hope this helps :)
7 0
3 years ago
Read 2 more answers
I need 20 characters, but the question is the photo
NISA [10]

Answer: The answer is in the first image.

Explanation: The explanation is in the second image.

3 0
2 years ago
How do you compare y-intercepts and rates of change
Sphinxa [80]
Not really sure what you mean by compare. The only thing I can think of is the y intercept is generally a good point to start from to count the rise/run
5 0
3 years ago
Other questions:
  • An animal shelter houses ferrets, cats, and dogs. There are 108 animals at the shelter. Of the
    11·1 answer
  • Explain lt Explain why the formula for finding the surface area of a rectangular prism is helpful.
    14·2 answers
  • What is the slope (m)
    8·1 answer
  • 20 What decimal does this model represent? Explain.
    7·1 answer
  • Please help me! How do I find the area of the shaded region in the circles?
    8·2 answers
  • The perimeter of Figure 1 is 26 in. The perimeter of Figure 2 is 132 in. Find the similarity ratio.
    14·1 answer
  • Which equation is equivalent to 2x^2-24x-14=0
    5·2 answers
  • I need help on question b please it hard
    9·1 answer
  • Em dois retângulos semelhantes, a ampliação foi de 10 cm por 12 cm, para 20 cm por 24 cm, qual a razão de semelhança (K)?
    14·1 answer
  • 3. Use proportional reasoning to answer the following question.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!