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
Hitman42 [59]
3 years ago
15

Recursive Power Function Write a function that uses recursion to raise a number to a power. The function should accept two argum

ents: the number to be raised and the exponent. Assume that the exponent is a nonnegative integer. Demonstrate the function in a program.
Computers and Technology
1 answer:
Firlakuza [10]3 years ago
4 0

Answer:

// here is code in c++.

#include <bits/stdc++.h>

using namespace std;

// recursive function to calculate power of number

int cal_pow( int b_num, int e_num )

{

  if ( e_num > 1 )

      return b_num * cal_pow( b_num, e_num - 1 );

  else

      return b_num;

}

int main()

{

   // variables to store inputs

  int b_num, e_num;

  cout <<"Enter the base (int): ";

  //read the base

  cin >> b_num;

  cout << "Enter the exponent (int): ";

  // read the exponent

  cin >> e_num;

// call the function and print the output.

  cout << b_num << " to the " << e_num << " power is: "

      << cal_pow( b_num, e_num ) << endl;

  return 0;

}

//

Explanation:

Read value of base and exponent from user. Call the function cal_pow() with parameter base and exponent. In this function, it will call itself and multiply base value while exponent becomes 1.When exponent becomes 1 then base value will be return by the recursive function. In the last recursive call it will give the base to power exponent

Output:

Enter the base (int): 3                                                                                                    

Enter the exponent (int): 5                                                                                                

3 to the 5 power is: 243

You might be interested in
An outdoor products company wants to test a new website design where customers can get information about their favorite outdoor
ExtremeBDS [4]

Answer:

Option (A) is the right answer for factors.

Option (B) is the right answer for factor levels.

Explanation:

As per the scenario, the company wants to see the effect of their new website design on their customers, for which the factor of time spent on the new website is right because it gives the company to acknowledge the data of time spent by a customer on the new website.

To reach the result of the factor, we have to work on the factor level, in which we will compare the time spent on the old website and the new website because it gives the company an idea of customers preferring which website design.

8 0
3 years ago
Suppose I have two DFAs D1, D2 and I perform the product construction on them to get a DFA for the union of their languages. Wha
Musya8 [376]

Answer:

Explanation:

If L(D1) = L(D2), the D has every state being final

If L(D1) = L¯(D2), the D has every state being final

If L(D1) = ∅, then L(D) = L(D2).

If L(D1)=Σ, L(D) = L(D2)

8 0
3 years ago
Fill in the blanks in the SQL statement below that will list the invoice number, invoice total and credit which is the total sum
ki77a [65]

Answer:

Following are the query and its explanation:

Explanation:

SELECT invoice_number , invoice_total , FORMAT ((payment_total +credit_total),2) AS Credit FROM invoices;

In the above given select command it selects two columns that are "invoice_number , invoice_total" in which it uses the format method that adds "payment_total  and credit_total" parameter value and divides the value, and holds its decimal point value use by the invoices table.

5 0
3 years ago
What is said to be the first mechanical calculator​
lakkis [162]

Answer:

Pascaline, also called Arithmetic Machine, the first calculator or adding machine to be produced in any quantity and actually used. The Pascaline was designed and built by the French mathematician-philosopher Blaise Pascal between 1642 and 1644.

Explanation: hope that helps

8 0
3 years ago
Read 2 more answers
What are the answers to 14 and 15
RoseWind [281]
The answer to 14 is c and the answer to 16 is a
6 0
4 years ago
Other questions:
  • Jesse has finished typing an essay for her college assignment and submitted it. The next day she received an email from her prof
    15·2 answers
  • In scratch coding what can I do with "when I recive messeage 1 "
    15·1 answer
  • Which of the following patterns should be used for the delimiter to read one character at a time using a Scanner object's next m
    7·1 answer
  • Which type of memory helps in reading as well as writing data? With the help of , a computer can read as well as write or modify
    11·3 answers
  • What is the answer to in Microsoft Word you can access the blank from the command command from the mini toolbar what is the corr
    10·2 answers
  • Player casts 'Assassinate' on 'Acolyte of pain'. Acolyte's owner will:
    6·2 answers
  • What is HTML. What is HTML ​
    15·2 answers
  • What command would Emile use in his word processing software to insert a bar chart that will automatically adjust to changes mad
    6·2 answers
  • Which of the following entries into the username and password fields will NOT cause us to gain admin access? You may assume that
    12·1 answer
  • A Chain of dry-cleaning outlets wants to improve its operations by using data from devices at individual locations to make real-
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!