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
The fall of the Berlin Wall and the emergence of a way to find things on the Web through the Netscape browser were two that was
Romashka-Z-Leto [24]
<h2>Answer:</h2>

Option 4. a way for software to communicate and become interactive

is the correct answer.

<h2>Explanation:</h2>

<h2>The fall of the Berlin Wall and the emergence of a way to find things on the Web through the Netscape browser were two that was browser were two events that flattened the world. A third platform was needed to change the world and that was a way for software to communicate and become interactive.</h2><h2 />

This question belongs to the advent of software and technology that has made world a global village. The factors that played important roles are Fall of Berlin wall and Netscape browser.

The third thing the added to connectivity among people is the production of softwares like Skype and other social applications that made it easier for people to interact with other and communicate faster.

<h2>i hope it will help you!</h2>
5 0
3 years ago
Which of the following is a reliable source of information: a book recommended from my professor, britannica, a blog, or wikiped
ratelena [41]
A book recommended from your professor is a reliable source of information.
8 0
3 years ago
Images, symbols, and diagrams are types of
kifflom [539]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct answer to this question is :

Graphics

Because Graphics are the visual representation of information without text. Images, symbols, and diagrams are types of graphics. These graphics can be used in presentations to present information visually.

While other options are not correct because:

Art objects are some images or painting that is the artistic creation of aesthetic value. While graphs are the visual presentation of data and there are different presentation objects in PowerPoint such as images, symbols, text, and diagrams, etc. But it is noted that images, symbols, and diagram are not types of presentation objects but it is a type of graphics elements/objects.

4 0
3 years ago
Assume inputFile is a Scanner object used to read data from a text file that contains a number of lines. Each line contains an a
anzhelika [568]

Answer:

words.hasNext()

Explanation:

Given the code snippet below:

  1.        while (inputFile.hasNextLine()) {
  2.            String word = "";
  3.            String line = inputFile.nextLine();
  4.            Scanner words = new Scanner(line);
  5.            while (words.hasNext()) {
  6.                word = words.next();
  7.            }
  8.            System.out.println(word); }
  9.    }

We have a inputFile Scanner object that can read data from a text file and we presume the inputFile has read several rows of data from the text file. So long as there is another line of input data available, the outer while loop will keep running. In each outer loop, one line of data will be read and assign to line variable (Line 3). Next, there is another Scanner object, words, which will take the current line of data as input. To get the last word of that line, we can use hasNext() method. This method will always return true if there is another tokens in its input. So the inner while loop will keep running so long as there is a token in current line of data and assign the current token to word variable. The word will hold the last token of current line of data upon exit from the inner loop. Then we can print the output (Line 8) which is the last word of the current line of data.

7 0
3 years ago
Siltstone is made mostly of _____.<br><br> A : silt<br> B : sand<br> C : shells<br> D : gravel
frez [133]
The best and most correct answer among the choices provided by the question is the second choice. <span>Siltstone is made mostly of silt. </span>I hope my answer has come to your help. God bless and have a nice day ahead!
6 0
3 years ago
Read 2 more answers
Other questions:
  • If the pc­doctor software is installed on a computer's hard drive, what two different ways can the program be started?
    7·1 answer
  • How does technology set a negative impact on the adolescent of our society?
    14·1 answer
  • Correspondence involves verbal communication. True False
    6·2 answers
  • What is batch processing?
    12·1 answer
  • How do I take this prodram back off
    15·1 answer
  • In theory, a hacker with a small but powerful directional antenna could access a wireless network from more than one mile away.
    7·1 answer
  • Project light with a system of lenses used for projecting slides or film into a screen.
    5·1 answer
  • The ______ Works on a single variable or constant. *​
    8·1 answer
  • A type of attack where the adversary intercepts network packets, modifies them, and inserts them back into the network is called
    13·1 answer
  • Write a 2 paragraph on an African American who has become successful in IT. Need help asap can’t think of anything
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!