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
vredina [299]
4 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]4 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
In a paragraph of no less than 125 words, explain what netiquette is and how it improves efficiency and productivity in the work
Ierofanga [76]

In very simple terms, netiquette is etiquette on the internet. It is a short form of network etiquette. It represents the importance of proper manners online. Common guidelines for good netiquette include being very courteous and avoiding instances of cyber-bullying. Although the specific protocols governing netiquette may differ depending on the forum being used, it is equally applicable to emails and surfing the internet, message boards, and chatting. In the workplace, netiquette implies that you have polite manners, and that you would want to build up relationships with people. By showing respect to your colleague through proper netiquette, it will show how productive you can be and as result, you will earn respect. Understanding netiquette in the workplace can save you from embarrassing moments. In sending job emails, for instance, always speak clearly and avoid using capitalized words, spelling errors, or slang.

8 0
4 years ago
Which of the following is NOT true about adjustment layers? brainbuffet
otez555 [7]

Answer the adjustment layers can not be used a lot?

Explanation: i think that was it

6 0
3 years ago
Probablilty can use to determine the likehood of specific_________​
maria [59]

the answer is occurrences

6 0
3 years ago
Read 2 more answers
The figure above shows a DC motor that contains a series field winding (F1) with a resistance of 10 , a parallel field winding (
shtirl [24]
Soooooooooooooooo you need to click c to get the right answer

 
5 0
3 years ago
Read 2 more answers
How to turn off location on iphone without person knowing
andrezito [222]

Answer:

airplane mode

Explanation:

5 0
3 years ago
Other questions:
  • Arpanet was developed by the united states so that there was a communication network that would survive a nuclear war. True or F
    11·1 answer
  • PHOTOSHOP QUESTION:
    14·1 answer
  • ) Suppose algorithm A takes 10 seconds to handle a data set of 1000 records. Suppose the algorithm A is of complexity O(n2). Ans
    12·1 answer
  • You are building a predictive solution based on web server log data. The data is collected in a comma-separated values (CSV) for
    7·1 answer
  • Write an algorithm which gets a number N, and prints all the natural numbers less than or equal N. 3.
    5·1 answer
  • How many bits per pixel does a black and white image require?
    15·1 answer
  • Can i add ADSence on bangla content in blogsopt website?
    12·1 answer
  • All of the followingshould be followed by entrepreneur for being effective
    10·1 answer
  • Which statement creates a StudentIDs object given the following code: public class StudentIDs&gt; { private TheType item1; priva
    15·1 answer
  • What is the function of cpu while processing data?​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!