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
Computer design replaced ______________
photoshop1234 [79]
The answer is c.-architectural talent and an eye for design.
4 0
4 years ago
The visitor's age is stored in the variable age, the day of the week is stored in a variable day, and the price in dollars is st
Hoochie [10]

Answer:

If a museum charges different prices based on the day of the week and age of the visitor. The pricing rules are shown below.

- On Tuesday and Thursday children 10 and under get in free ($ 0).

- For all other days and ages the cost is ten dollars ($ 10).

The code in python is;

if (day == 'Tuesday' or day == 'Thursday') and age <= 10:

   price = 0

else:

   price = 10

Explanation:

The logic of the algorithm suggests that that the conditional if-statement assigns zero to the price variable if the day variable is either Tuesday or Thursday and the child's age is 10 or below but assigns 10 to the price variable if the condition is not met.

4 0
3 years ago
Desktop publishing design tools are represented by A. icons. B. windows. C. trackballs. D. modems.
AnnZ [28]
The best answer is A
Windows are the screens you can maximize and minimize.
Trackballs make the mouse move.
Modems are associated with internet connection.
Those three answers are unrelated leaving icons to be the most reasonable.
3 0
3 years ago
It is ok to sell services on Xbox in exchange for real-world money
Sati [7]
Is this a true or false question? If it is let me know and I can help! (:
6 0
4 years ago
Read 2 more answers
Search engines use indexes created by web _________ to provide fast searches.
Nastasia [14]
Search engines use indexes created by web crawlers to provide fast searches.
3 0
3 years ago
Other questions:
  • Which computer device helps you input data in the form of text, numbers, and commands?
    9·1 answer
  • Two columns of a relational table can have the same names. <br> a. True <br> b. False
    15·1 answer
  • Please Help Fast!!!!!! Brainliest for First to answer!!! Conflict resolution is the process of solving disputes and disagreement
    5·1 answer
  • Negative glue effects
    8·1 answer
  • Write an algorithm that receives a number from the user (you can store the number in a variable called N). Then the algorithm sh
    8·1 answer
  • Which network device regenerates the data signal without segmenting the network? modem?
    15·1 answer
  • Three batch jobs, A through E, arrive at a computer center at almost the same time. They have estimated running times of 10, 6,
    6·1 answer
  • Identify the correct answer in each item. Write your answer on the blank provided before
    13·1 answer
  • When documenting one author in reference in a text, which is correct?.
    7·1 answer
  • Write a program that stores the maximum of three values. The values are stored in $s0, $s1, and $s2. Store the result in $s3. No
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!