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
If the computer has an encrypted drive, a ____ acquisition is done if the password or passphrase is available. a. passive b. sta
Aleonysh [2.5K]

Answer: C. Live

Explanation:

A live acquisition is where data is retrieved from a digital device directly via its normal interface such as activating a computer and initiating executables. Doing so has a certain level of risk because data is highly likely to be modified by the operating system. The process becomes significantly more common likely with less available disk space to the point of completely impractical to image.

7 0
1 year ago
Write a copy assignment operator for CarCounter that assigns objToCopy.carCount to the new objects's carCount, then returns *thi
Olin [163]

The following cose will be used to copy assignment operator for CarCounter

<u>Explanation:</u>

Complete Program:

#include <iostream>

using namespace std;

class CarCounter

{

public:

CarCounter();

CarCounter& operator=(const CarCounter& objToCopy);

void SetCarCount(const int setVal)

{

 carCount = setVal;

}

int GetCarCount() const

{

 return carCount;

}

private:

int carCount;

};

CarCounter::CarCounter()

{

carCount = 0;

return;

}

// FIXME write copy assignment operator

/* Your solution goes here */

CarCounter& CarCounter::operator=(const CarCounter& objToCopy)

{

if(this != &objToCopy)

 carCount = objToCopy.carCount;

return *this;

}

int main()

{

CarCounter frontParkingLot;

CarCounter backParkingLot;

frontParkingLot.SetCarCount(12);

backParkingLot = frontParkingLot;

cout << "Cars counted: " << backParkingLot.GetCarCount();

cout << endl << endl;

system("pause");

return 0;

}

5 0
2 years ago
Which option describes wearable technology? A. the incorporation of technology into objects we use regularly B. rugged technolog
vichka [17]

The correct answer is

A.  the incorporation of technology into objects we use regularly

#Platogang

8 0
2 years ago
If a user was complaining about a "slow computer" due to a program that uses a significant amount of memory, what part or parts
Sedaia [141]

Answer:

The Random-Access Memory (RAM) should be upgraded.

Explanation:

Since the particuar apllication is taking alot of memory space it means that an ugrade/ installation of a bigger RAM would help the system work better while using the program

6 0
1 year ago
Given a scanner reference variable named input that has been associated with an input source consisting of a sequence of strings
Makovka662 [10]

The code that examines all the strings in the input source and determines how long the longest string (or strings are) is the following:

total = 0; % initial value is zero, in every while loop it will be incremented

while(input.hasNextInt()){

total += input.nextInt( );

}

7 0
1 year ago
Read 2 more answers
Other questions:
  • What is the first step to apply the line and page breaks options to groups of paragraphs in a Word document?
    8·2 answers
  • // This pseudocode is intended to determine whether students have
    5·1 answer
  • Given an int variable k, an int array incompletes that has been declared and initialized, an int variable studentID that has bee
    10·1 answer
  • You can deal with gaps in an PHP array in all but one of the following ways. Which one is it? a. Use the array_values() function
    14·1 answer
  • If a class has member variables that are pointers, you must ensure that you implement ____.
    6·1 answer
  • CHALLENGE ACTIVITY 3.7.2: Type casting: Reading and adding values.
    10·1 answer
  • 1.the following code example would print the data type of x, what data type would that be?
    12·1 answer
  • Write a method called printRangeOfNumbers that accepts a minimum, maximum numbers as parameters and prints each number from mini
    6·1 answer
  • PLEASE HELP!!!
    11·1 answer
  • Identify the tips to create a well-designed digital portfolio.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!