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
mihalych1998 [28]
3 years ago
13

11.11 LAB: Number pattern Write a recursive function called PrintNumPattern() to output the following number pattern. Given a po

sitive 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. For this lab, do not end output with a newline. Ex. If the input is:
Computers and Technology
2 answers:
musickatia [10]3 years ago
6 0

Answer:

The function in C++ is as follows:

int itr, kount;

void printNumPattern(int num1,int num2){

   if (num1 > 0 && itr == 0) {

       cout<<num1<<" ";

       kount++;

       printNumPattern(num1 - num2, num2);

   } else {

       itr = 1;

       if (kount >= 0) {

           cout<<num1<<" ";

           kount--;

           if (kount < 0) {

               exit(0);}

               printNumPattern(num1 + num2, num2);}}

}

Explanation:

We start by declaring global variables itr and kount

int itr, kount;

The function is defined here

void printNumPattern(int num1,int num2){

If num1 and itr are greater than 0 , then

   if (num1 > 0 && itr == 0) {

Output num1, followed by a space

       cout<<num1<<" ";

Increment counter by 1

       kount++;

Call the recursion

       printNumPattern(num1 - num2, num2);

If otherwise

   } else {

Set itr to 1

       itr = 1;

If counter is 0 or positive

       if (kount >= 0) {

Output num1, followed by a space

           cout<<num1<<" ";

Decrease counter by 1

           kount--;

If counter is negative

           if (kount < 0) {

Exit function

               exit(0);}

Call the recursion

              printNumPattern(num1 + num2, num2);}}

}

Law Incorporation [45]3 years ago
4 0

Answer:

void PrintNumPattern(int start, int delta) {

cout << start << " ";

if (start > 0) {

 PrintNumPattern(start - delta, delta);

 cout << start << " ";

}

}

void main()  

{  

PrintNumPattern(12, 3);

}

Explanation:

Looking at the "palindrome" symmetry of the output, you want one nesting level of the function to print the output twice. Then you also don't need global variables.

You might be interested in
Which device is connected to a port on a switch in order to receive network traffic?
inysia [295]

Answer:

"Passive IDS" is the appropriate answer.

Explanation:

  • A framework that is designed mostly for monitoring and analyzing internet traffic operations and alerting a user or administrator about possible bugs, as well as disruptions, is known to be passive IDS.
  • This IDS cannot carry out certain preventive as well as remedial processes as well as operations by itself.
6 0
3 years ago
What report indicates the last page users viewed before leaving a website?.
Serhud [2]

Answer:

You can find the last page users viewed before leaving the website on the “Exit Pages” report under “Site Content”

Explanation:

This can also give you a percentage of exits as well as the number of exits from a page.

If you have an important page, (using a silly example, a picture of your dog) that you really want people to see, you can check the exit pages and see how many people are actually seeing this <em>great</em> picture of your dog, or adjust your site if needed.

Have a nice day!

     I hope this is what you are looking for, but if not - comment! I will edit and update my answer accordingly.

- Heather

3 0
2 years ago
Steps to run a Q-BASIC programme<br>​
jarptica [38.1K]

Answer:

Cls

Read

Input

Print

END

5 0
3 years ago
A.) Write a code statement to assign the value 7.3 to a variable with an identifier<br> timer.
Georgia [21]

The code segment that assigns value to the variable named timer is:

timer = 7.3

<h3>How to write the code</h3>

To assign a value to a variable, we make use of the following syntax:

variable = value

In this case;

The variable is timer and the value is 7.3

Hence, the required code segment is: timer = 7.3

Read more about code segments at:

brainly.com/question/18430675

8 0
2 years ago
Help please<br>Who will give the answer I'll mark him/her as brainlist..​
kolbaska11 [484]

Answer:

We will be using Average function of Excel Calculation sheet.

Its Syntax in Calc sheet is : =AVERAGE (number1, [number2], ...)

or you can use =Average and then click on the first cell and drag the whole row till end and close the brackets. It will calculate the average of that row.

Once you have applied average function on first row, you can drag this cell down the column and it will replicate the same function for respective rows.

4 0
3 years ago
Other questions:
  • Add the following 2's complement binary numbers. Also express the answer in decimal. a. 01+ 1011b. 11+ 01010101c. 0101+ 110d. 01
    8·1 answer
  • Why is printer an output device​
    14·2 answers
  • My sister put my phone in the microwave and I'm pretty sure the battery blew up. I'm too scared to open the microwave. What do I
    11·1 answer
  • What does place value mean with binary?
    6·1 answer
  • Anne creates a web page and loads a CSS style script along with the page. However, the entire page appears black and she cannot
    6·1 answer
  • Source Code for TF2 - Please insert it here
    14·1 answer
  • The events that happen in a story are called the _________________.
    14·2 answers
  • Look over the image in the top section and choose which piece from the bottom should be placed in the question mark (?) that wou
    11·1 answer
  • Draw and implement of an organization which have 125 employees. use the following features 1.email services 2.lan communication
    8·1 answer
  • When delivering 2023 murano, demonstrate how to turn the driver assistance technologies on or off using ________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!