answer.
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
vredina [299]
2 years ago
5

Write a recursive method called printNumPattern() to output the following number pattern. Given a positive integer as input (Ex:

12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached. Ex. If the input is:
Computers and Technology
1 answer:
TiliK225 [7]2 years ago
7 0

Answer:

See Explanation Below

Explanation:

// C++ printNumPattern() recursive method

// Comments are used for explanatory purpose

// Only the recursive is submitted

// Method starts here

void printPattern(int num1, int num2, bool dec)  

{  

// Print num2.  

cout << num2 << " ";  

//Printing to num1

if (dec == false && num1 ==num2)  {

 return;  }

// Printing to 0 or negative.  

if (dec)  

{  

// If num2 is greater than num2

if (num2-num1 > 0)  

 printPattern(num1, num2-num1, true);  

else // recur with false dec  

 printPattern(num1, num2-num1, false);  

}  

else // If dec is false.  

 printPattern(num1, num2+num1, false);  

}  

//End of recursive

You might be interested in
A blood bank maintains two tables - DONOR, with information about people who are willing to donate blood and ACCEPTOR, with info
Kipish [7]

Answer:

The sql query is given below.

Since we need to count of males and females for a particular blood group, we put xxx for the blood group.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%") as Male_Donors,

COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%") as Female_Donors

FROM DONOR

WHERE BG = xxx;

Explanation:

The clauses in the query are as follows.

1. SELECT: all the columns required in the output are put in this clause.

2. FROM JOIN ON: the table(s) from which the above columns are taken are put in this clause.

3. WHERE: any condition required to filter the output is put in this clause.

The query is explained below.

1. Find the number of male donors. Number of anything can be found using COUNT() function. A query is required since gender is included in deciding the type of donor.

2. The query is defined to find number of male donors as follows.

COUNT( SELECT DID FROM DONOR WHERE GENDER LIKE "M%"; )

3. In the previous query, LIKE operator is used since it is not defined what value is stored for male donors.

4. Similarly, the query to find the number of female donors is formed.

COUNT( SELECT DID FROM DONOR WHERE GENDER LIKE "F%"; )

5. Next, the final query is formed as follows.

SELECT: both COUNT() functions will come here.

FROM: table name

WHERE: specific blood group will be put here

GROUP BY: this clause is optional and is not used in this query.

HAVING: this clause is optional and is not used in this query.

6. The query after putting all clauses is shown below.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%"),

COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%")

FROM DONOR

WHERE BG = xxx;

7. Alias is used in the above query for each column to get the final query.

SELECT COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "M%") as Male_Donors, COUNT(SELECT DID FROM DONOR WHERE GENDER LIKE "F%") as Female_Donors

FROM DONOR

WHERE BG = xxx;

7 0
2 years ago
suppose that you have been given the task of writing an unloader - that is, a piece of software that can take the image of a pro
Brums [2.3K]
............;(&;&;$;!:$:!;$;8;$;$;;$;&8;$;$;$;$;$;$;$;$;$;
8 0
2 years ago
The wi-fi protected access (wpa2) uses _____ to obtain a master key, which is in turn used to negotiate for a key that will be u
harina [27]
I am definitely sure that wpa2 uses Extensible Authentication Protocol (EAP) <span>to obtain a master key, which is in turn used to negotiate for a key that will be used for a session. It provides the transport and usage of key which is generated by EAP methods. It's widely used in p2p (point-to-point) connections and wireless networks.</span>
6 0
2 years ago
Which of the following is true about simulation games? A. Simulation games involve competing in a sport against other players. B
WARRIOR [948]
<span>Simulation games recreate a real-world environment. </span>
6 0
2 years ago
Read 2 more answers
A computer has a pipeline with four stages. each stage takes the same time to do its work, namely, 1 nsec. how many instructions
prisoha [69]

In figuring, a pipeline, otherwise called an information pipeline, is a lot of information preparing components associated in arrangement

Further explanation:

In figuring, a pipeline, otherwise called an information pipeline, is a lot of information preparing components associated in arrangement, where the yield of one component is the contribution of the following one. The components of a pipeline are frequently executed in parallel or in time-cut style.

Instruction travelling:

999,999,997 guidelines for each second. The pipeline has 3 nsec of straightforward figurings, at that point finishes a guidance in each ensuing nsec.  

3nsec (for first guidance to go down the pipeline).10^9 ns every second. 10^9 – 3 = 999999997 directions.

Instruction per second:

MIPS - Million guidelines for each second  

Million guidelines for each second (MIPS) is a more established, outdated proportion of a PC's speed and power, MIPS measures generally the quantity of machine directions that a PC can execute in one second.

Per second:

Million directions for each second (MIPS) is a more established, old proportion of a PC's speed and power, MIPS measures generally the quantity of machine guidelines that a PC can execute in one second. Be that as it may, various directions require pretty much time than others, and there is no standard strategy for estimating MIPS. Moreover, MIPS alludes just to the CPU speed, while genuine applications are commonly constrained by different elements, for example, I/O speed

Answer Details:

Subject: Computer and technology

Level: College.

Key Words:

Further explanation:

Per second:

Instruction per second:

Instruction travelling:

For further Evaluation:

brainly.com/question/6362387

brainly.com/question/12938965

6 0
2 years ago
Read 2 more answers
Other questions:
  • The ________ method is based on simple arithmetic. The process involves dividing the bits of a frame into equal segments, adding
    11·1 answer
  • A file named data.txt contains an unknown number of lines, each consisting of a single integer. Write some code that creates two
    14·2 answers
  • An expression containing the operator &amp;&amp; is true either or both of its operands are true. True/False
    15·1 answer
  • _____________ involves the deployment of malware that secretly steals data in the computer systems of organizations, such as gov
    13·1 answer
  • When handling project scope creep, which are two things that all parties involved need to be aware of?
    6·1 answer
  • in a small office, there are 5 computers, a network printer, and a broadband connection to the internet. what devices are needed
    9·1 answer
  • Write the definition of a function named averager that receives a double parameter and return-- as a double -- the average value
    12·1 answer
  • (1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the arr
    7·1 answer
  • Suggest how the following requirements might be rewritten in a quantitative way. You may use any metrics you like to express the
    7·1 answer
  • Write a program that takes a single integer input from the user and stores it in a variable. Your program should increase the va
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!