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
Which of the following provides a suite of integrated software modules for finance and accounting, human resources, manufacturin
zzz [600]

Answer:

B) ERP systems

Explanation:

ERP which means Enterprise Resource Planning is a software that uses a centralized database, it helps to hasten business processes thereby reducing the use of manual labour. Some of the integrated software modules which it provides are:

*Finance, Accounting.

*Human resource.

*Manufacturing and production.

*Sales and marketing.

The ERP system does not really need the total involvement of a human because it has a database where information stored is used in the daily execution of tasks, it can also be used to measure the productivity and profitability of the business.

6 0
2 years ago
Deanna wants to have an exciting presentation and adds animations. She wants her bullet points to be animated through motion. Wh
aivan3 [116]
Fade in is the correct answer
3 0
2 years ago
Read 2 more answers
Which of the following is not true of how computers represent complex information
mote1985 [20]

Answer: c. Depending on context the same sequence of bits may represent different types of information.

Explanation:

The options for the question are:

A. Computing devices use patterns of bits to represent complex information

B. Abstraction helps represent complex information by surfacing complexity that might otherwise be hidden

C. Depending on context the same sequence of bits may represent different types of information

D. Common abstractions that are represented by computing devices include numbers, characters, and color.

The following are true of how computers represent complex information:

• Computing devices use patterns of bits to represent complex information

• helps represent complex information by surfacing complexity that might otherwise be hidden

• Common abstractions that are represented by computing devices include numbers, characters, and color.

Therefore, the option that is not true of how computers represent complex information is that "depending on context the same sequence of bits may represent different types of information".

5 0
1 year ago
Read 2 more answers
Write a code segment to change the name of the Thing object something such that the new name consists of the old name with one c
ololo11 [35]

Answer:

import random

def name_change( name: list ) -> list :

   choice = random.choice( name )

   choice_index = name.index( choice )

   name.pop( choice_index )

   return name

Explanation:

The python source code above makes use of the random package to select an item from a list in the function "name_change" and the index of that item is gotten fro the list and popped from the list "name", then the name is returned.

To call the function, assign it to a variable and add a list ( must be a list ) as its argument then print the result.

6 0
1 year ago
For the (pseudo) assembly code below, replace X, Y, P, and Q with the smallest set of instructions to save/restore values on the
Dimas [21]

Answer:

Explanation:

Let us first consider the procedure procA; the caller in the example given.

  Some results: $s0,$s1,$s2, $t0,$t1 and $t2 are being stored by procA. Out of these registers, few registers are accessing by procA after a call to procB. But, procB might over-write these registers.

       Thus, procA need to save some registers into stack first before calling procB, .

      only $s1,$t0 and $t1 are being used after return from procB in the given example,

       Caller saves and restores only values in $t0-$t9, according to MIPS guidelines for caller-saved and callee-saved registers, .

       Thus, procA needs to save only $t0 and $t1.

    jal instruction overwrites the register $ra by writing the address, to which the control should jump back, after completing the instructions of procB, when procB is called,.

       Therefore, procA also need to save $ra into stack.

 ProcA is writing new values into $a0,$a2, procA must save $a0 and $a1 first before calling procB, .

     In the given example, after return from procB, only $a0 is being used. It is therefore enough to save $a0.

   Also, procA needs to save frame pointer, which points the start of the stack space for each procedure.

       Generally, as soon as the procedure begins, frame pointer is set to the current value of the stack pointer,.

Let us consider the procedure procB; the callee in the given example.

 The callee is responsible for saving values in $s0-$s7 and restoring them before returning to caller, this is according to MIPS guidelines for caller-saved and callee-saved registers,

   procB is expected to over-write the registers $s2 and $t0. Nonetheless, in the first two lines, procB might over-write the registers $s0 and $s1.

   Thus, procB is responsible for saving and restoring $s0,$s1 and $s2.

X:

We need to create space for 5 values on the stack since procA needs to save $a0,$ra,$t0,$t1 and $fp(frame pointer), . Each value(word) takes 4 bytes.

$sp = $sp – 20 # on the stack, create space for 5 values

sw $a0, 16($sp) # store the result in $a0 into the memory address

               # indicated by $sp+20

sw $ra, 12($sp) # save the second value on stack

sw $t0, 8($sp) # save the third value on stack

sw $t1, 4($sp) # save the fourth value on stack

sw $fp, 0($sp) #  To the stack pointer, save the frame pointer

$fp = $sp      #  To the stack pointer, set the frame pointer

Y:

lw $fp, 0($sp) #  from stack, start restoring values

lw $t1, 4($sp)

lw $t0, 8($sp)

lw $ra, 12($sp)

lw $a0, 16($sp)

$sp = $sp + 20 # decrease the size of the stack

P:

$sp = $sp – 12 #  for three values, create space on the stack

sw $s0, 0($sp) # save the value in $s0

sw $s1, 0($sp) # save the value in $s1

sw $s2, 0($sp) # save the value in $s2

Q:

lw $s0, 0($sp) #  from the stack, restore the value of $s0

lw $s1, 0($sp) #  from the stack, restore the value of $s1

lw $s2, 0($sp) #  from the stack, restore the value of $s2

$sp = $sp + 12 # decrease the stack size

8 0
2 years ago
Other questions:
  • One of the most toxic components of a computer is the
    11·1 answer
  • If a car's is malfunctioning, people in the car will become ill when driving long distances, especially if the windows are close
    6·2 answers
  • Splunk uses ________ to categorize the type of data being indexed..
    11·2 answers
  • python Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value i
    7·1 answer
  • When your tire blows out in the middle of a drive, you should _____. A. let go of the steering wheel B. pump the brakes immediat
    13·2 answers
  • Given: an int variable k, an int array current Members that has been declared and initialized, an int variable memberID that has
    11·1 answer
  • c++ Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value is c
    14·2 answers
  • A company moves a popular website to a new web host. Which of the following will change as a result?
    15·1 answer
  • Write a method called printRangeOfNumbers that accepts a minimum, maximum numbers as parameters and prints each number from mini
    6·1 answer
  • 1.21 LAB: Divide by x
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!