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
Rufina [12.5K]
3 years ago
5

Implement a program that uses a recursive function to count from N (provided by the user in main, <= 100) down to 1 and inste

ad of displaying 0 it will display the message: I’ve learned how to use recursion! All output comes from the recursive function. The recursive function validates the number range, not main. Add a row to the bottom of your test plan and explain what are the two things one must identify in order to write a recursive function.
Computers and Technology
1 answer:
Lostsunrise [7]3 years ago
6 0

Answer:

C++.

Explanation:

#include <iostream>

using namespace std;

//////////////////////////////////////////////////////////////

void countDown(int N) {

   if ((N > -1) && (N <= 100)) {

       if (N == 0) {

           cout<<"I've learned how to use recursion!";

       }

       else {

           cout<<N<<endl;

           countDown(N-1);

       }

   }

   else

       cout<<"Invalid Range."<<endl;

}

//////////////////////////////////////////////////////////////

int main() {

   int N;

   ////////////////////////////////

   cout<<"Enter number: ";

   cin>>N;

   countDown(N);

   ////////////////////////////////

   return 0;

}

////////////////////////////////////////////////////////////////////////////////////////////

Any Recursive function has two main things.

First is the break condition or base case, without it, the function would never stop calling itself and go into infinite loop.

In the above example, the base case was "N == 0".

Second, and the more difficult thing, is to write a proper recurring statement. This part is basically what recursion is all about, i.e. solve problems by breaking them down into smaller problems and then combining the result.

In the above example, this was "countDown(N-1)".

You might be interested in
Whenever I go onto Google Chrome, the words are in Spanish! How can I make the words be back in English again? Please let me kno
ivann1987 [24]

Answer:

Go to google setting look up english on setting bar and it should have the option to change or add languages make sure you press save when choosing english

Explanation:

5 0
3 years ago
PLEASE HURRY!!<br> Look at the image below
Tanzania [10]

Answer:

source append (6,2)

Explanation:

Mark me as brain list

7 0
3 years ago
A Python data model defining the state of a game for Tic-Tac-Toe. You must fully describe the notion of a state of the game, lim
Artist 52 [7]

Answer:

Check the explanation

Explanation:

Here in this game of Tic-Tac-Toe, it is using the TPGE engine which is a Tiny Python Game Engine. Let's talk about its functions like:-

def image_type(img): In this function, it is simply taking image as a parameter and returning its object type like DISC if the image is in graphical form, TEXT if it is a string, and LINE if it is other than the mentioned object.

def convert_image(img):  In this function, it is simply taking image as a parameter and returning an equivalent graphical object as understood by John Zelle's. Mainly comparing for three things in this function and those are: if image equals to DISC then it is calling convert_circle(function), if image equals to LINE then it is calling convert_line(function), and if image equals to TEXT then it is calling convert_text(function),

def convert_circle(x): This function takes a list( a group of values) and makes a circle at the center of the window and the circle's radius is coming from the list.

convert_text, convert_line, convert_circle are only creating text, line, and circle and then returning it.

def graphical_elements(images): This function is taking image as a parameter and then extracting shape and color from the image and then calling convert_image(shape) and convert_type(shape) and it gives us graphic and kind respectively. Now it is checking whether kind equals to DISC If yes then filling color on the window else, setting the outline of the window

def run(): Here it is finally running the game with required parameters, the whole game is continously running under the while loop.

That's all

8 0
4 years ago
Which situation best describes the prosumer effect?
elena-s [515]

C

Explanation:

https://www.sciencedirect.com/science/article/pii/S2405844019356750

8 0
4 years ago
True or False
krok68 [10]

I think that the answer is false. But I'm not sure.Let meknow if I'm right.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which two jobs have high demand need for practitioners( have a skill shortage)
    13·1 answer
  • One thing we might want to know, given an input to a chatbot, is if the input is a question.
    10·1 answer
  • Premiere Pro CS4 is the first version to be optimized for _______operating systems, although it is not natively 64-bit.
    10·1 answer
  • Discuss two things you want to know about driving
    12·1 answer
  • A computer with a frequency 2 GHZ and its average cycle per instruction is 2. what is the MIPS of the computer?
    6·1 answer
  • The proxy statement issued by a corporation is a requirement of: a. The Securities &amp; Exchange Commission (SEC) b. The Financ
    5·1 answer
  • Symbic Foods, a chain of fast food restaurants, has included a drop-down menu on its main Web site. With this drop-down menu, pe
    13·1 answer
  • Brenda's meeting with the web developer of her retail website concerning the integration of conversion tracking using Google Ads
    14·1 answer
  • Assume user_name equals "Tom" and user_age equals 22. What is printed on the console when the following statement is executed? c
    14·1 answer
  • Task 1: Alex has created the following code using Scratch and expected it to move backwards and forwards across the screen. Howe
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!