Computers and Technology

Write code to complete RaiseToPower(). Sample output if userBase is 4 and userExponent is 2 is shown below. Note: This example is for practicing recursion; a non-recursive function, or using the built-in function pow(), would be more common. 4^2 = 16
#include
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(void) {
int userBase = 0;
int userExponent = 0;
userBase = 4;
userExponent = 2;
printf("%d^%d = %d\n", userBase, userExponent, RaiseToPower(userBase, userExponent));
return 0;
}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:30, electrofy456
Active listen eliminates barries to communication true or false
Answers: 1
image
Computers and Technology, 23.06.2019 04:20, milkshakegrande101
4. a1. vince owns a television repair shop that is insured undera commercial package policy. the policy includes thebuilding and personal property coverage form and thecauses-of-loss broad form. the declarations page indicatesthat coverage applies to both the building and the namedinsured's business property. explain whether or not thefollowing losses would be covered under his policy. a. a fire occurs on the premises, and the building isbadly damaged. b. a burglar steals some money and securities from anunlocked safe. c. a business computer is damaged by vandals whobreak into the shop after business hours. d. a tornado touches down near the store. several tel-evision sets of customers in the shop for repair aredamaged in the storm. til
Answers: 2
image
Computers and Technology, 25.06.2019 04:10, danny123421
8. create an abstract student class for parker university. the class contains fields for student id number, last name, and annual tuition. include a constructor that requires parameters for the id number and name. include get and set methods for each field; the settuition() method is abstract. create three student subclasses named undergraduatestudent, graduatestudent, and studentatlarge, each with a unique settuition() method. tuition for an undergraduatestudent is $4,000 per semester, tuition for a graduatestudent is $6,000 per semester, and tuition for a studentatlarge is $2,000 per semester. write an application that creates an array of at least six objects to demonstrate how the methods work for objects for each student type. save the files as student. java, undergraduatestudent. java, graduatestudent. java, studentatlarge. java, and studentdemo. java.
Answers: 1
image
Computers and Technology, 25.06.2019 05:00, mytymikey123
How does computer network work in a paragraph
Answers: 1
Do you know the correct answer?
Write code to complete RaiseToPower(). Sample output if userBase is 4 and userExponent is 2 is shown...

Questions in other subjects:

Konu
Mathematics, 24.11.2020 03:30