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
Tcecarenko [31]
3 years ago
10

(C++) Write code to complete RaiseToPower(). Sample output if userBase is 4 and userExponent is 2 is shown below. Note: This exa

mple is for practicing recursion; a non-recursive function, or using the built-in function pow(), would be more common.4^2 = 16Given: #nclude using namespace std;int RaiseToPower(int baseVal, int exponentVal){int resultVal = 0;if (exponentVal == 0) {resultVal = 1;}else {resultVal = baseVal * //your solution goes here;}return resultVal;}int main() {int userBase = 0;int userExponent = 0;userBase = 4;userExponent = 2;cout << userBase << "^" << userExponent << " = "<< RaiseToPower(userBase, userExponent) << endl;return 0;}

Computers and Technology
1 answer:
Degger [83]3 years ago
5 0

Answer:

Following are the code to this question:

RaiseToPower(baseVal, exponentVal-1);//calling method RaiseToPower and in second parameter we subtract value  

resultVal = baseVal * RaiseToPower(baseVal, exponentVal-1);//defining resultVal variable that calculate baseVal and method value

Explanation:

In the above-given code inside the "RaiseToPower" method is defined that accepts two parameters, which are "baseVal and exponentVal" and inside the method, an integer variable "resultVal"  is defined, that holds a value that is 0.

  • In the next step, if the conditional statement is used, in if the block it checks the "exponentVal" variable value that is equal to 0, if it is true it assigns value 1 in "resultVal" otherwise it will go to else block in this block, the "resultVal" variable holds "baseVal" variable value and call the "RaiseToPower" method, and multiply the baseVal and method and store its value in resultVal and return the value.
  • Inside the main method, two integer variable userBase, userExponent is defined that holds a value and calls the above method and prints its return value.

please find the attachment of the code file and its output.

You might be interested in
The largest type of computer system with the most extensive storage capacity and the fastest processing speeds is a ________.
azamat
Super Computer. Hope I helped.
5 0
3 years ago
This variable controls the number of times that the loop iterates. A. Counter variable B. Loop control variable C. Running total
Norma-Jean [14]

Answer:

B) Loop control Variable

Explanation:

When programming, A loop control variable is used to control the number of iterations for a program loop. By convention programmers love to call this variable counter, i, j, n etc. The control variable when defined will determine the number of times a loop will execute. See the example bellow in C++ where we use a for loop to print the word "Hello" 5 times

<em>#include <iostream></em>

<em>using namespace std;</em>

<em>int main()</em>

<em>{</em>

<em>  for(int counter = 0; counter<5; counter++){</em>

<em>    cout<<"Hello"<<endl;</em>

<em>  }</em>

<em>    return 0;</em>

<em>}</em>

In this code snippet, the control variable is called counter and the condition is that counter will run from 0 to 4. So we get the world Hello printed five times

8 0
3 years ago
Tommy only thinks about his own gains and does not care about the team objectives. What quality is he demonstrating?
GarryVolchara [31]
He is having an extreme ego and pride and is being greedy and unrespectful 
4 0
3 years ago
Read 2 more answers
What is Information system
LenaWriter [7]
MIS just search it on google
6 0
3 years ago
Read 2 more answers
Which is an example of an installation?
Ede4ka [16]
<span>illustrates how to create a simple Windows Installer package that installs an application.

</span>
4 0
4 years ago
Read 2 more answers
Other questions:
  • When a user runs an application, what transfers from a storage device to memory?
    6·1 answer
  • Which statement is true regarding achievers?
    8·1 answer
  • Which of the following best meets the requirements of a strong password?
    5·2 answers
  • When you want to specify multiple criteria, and all criteria must be true for a record to be included in the results, when the _
    9·1 answer
  • Your program will read in an existing text file. You want the program to terminate if the file does not exist. Which of the foll
    10·1 answer
  • In which step is a metaphor used in planning a multimedia presentation
    15·1 answer
  • What is the role of memory in a computer​
    11·1 answer
  • Write<br> algorithm to read 100 numbers<br> then display the largest.
    9·1 answer
  • Write the program to accept the radius of circle and find its diameter coding
    11·1 answer
  • Explain the role of ICT in banks​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!