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
AleksandrR [38]
2 years ago
8

Write a function named power that accepts two parameters containing integer values (x and n, in that order) and recursively calc

ulates and returns the value of x to the nth power.
Computers and Technology
1 answer:
lianna [129]2 years ago
8 0

Answer:

Following are the code to the given question:

int power(int x, int n)//defining a method power that accepts two integer parameters

{

if (n == 0)//defining if block to check n equal to 0

{

return 1; //return value 1

}

else//defining else block

{

x = x * power(x, --n); //use x variable to call method recursively

}

return x; //return x value

}

Explanation:

In the above-given code, a method power is defined that accepts two integer variable in its parameter, in the method a conditional statement is used which can be defined as follows:

  • In the if block, it checks "n" value, which is equal to 0. if the condition is true it will return value 1.
  • In the else block, an integer variable x is defined that calls the method recursively and return x value.
You might be interested in
Sal Kan earned $3,000.00, But he is only getting $1,585.00 on his pay check to
svetlana [45]

Answer:

Usually, it's because of taxes and insurance.

3 0
3 years ago
2. Why do old video games have large pixels and images with jagged edges?
egoroff_w [7]

Answer:

A

Explanation:

cuz yea

3 0
1 year ago
Read the description of Mike’s work, and identify his profession. Mike’s job is to record sounds in a studio. He studies a video
kipiarov [429]
Mike is a Sound Engineer
7 0
2 years ago
Read 2 more answers
A scientific question may lead to a(n) , which can be tested.
kari74 [83]
A hypothesis or educated guess
6 0
3 years ago
Read 2 more answers
In a school 50% of the students are younger than 10, 1/20 are 10 years old and 1/10 are older than 10 but younger than 12, the r
Zielflug [23.3K]

Answer: 10 students

Explanation:

Students younger than 10 = 50%

Students that are 10years old = 1/20 = 1/20 × 100 = 5%

Students that are older than 10 but younger than 12 = 1/10= 1/10 × 100 = 10%

Students that are 12 years or older

= 100% - (50% + 5% + 10%)

= 100% - 65%

= 35%

This means that 35% of the students are 12 years or older and we've been given the number as 70.

Let's say the total number of students is x. Therefore,

35% of x = 70

0.35 × x = 70

0.35x = 70

x = 70/0.35

x = 200

The total number of students is 200.

Therefore, the number of students that are 10years will be:

= 1/20 × 200

= 10 students

Therefore, 10 students are 10 years.

3 0
2 years ago
Other questions:
  • What type of rain happens when cold air meets warm air
    14·1 answer
  • What action makes RAM on your computer disappear?
    12·2 answers
  • Which of the following functions does a browser perform?
    7·2 answers
  • Digital libraries are often available to students and/or employees at colleges, schools, and BLANK institutions.
    15·1 answer
  • Legal functions are the most important area of IG impact. Under the FRCP amendments, corporations must proactively manage the e-
    9·1 answer
  • Create and Provide complete program that includes a comments header with your name, course, section and other program details an
    9·1 answer
  • In chapter 11, we finally learn how the book got its title. What is the sign of the beaver? Is that what you expected when you r
    13·1 answer
  • 12.
    10·1 answer
  • Select the correct answer from each drop-down menu
    7·1 answer
  • What does mean in computer science
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!