Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code in c .1 MetroPCS 8:08 PM 55% CS1050 Prelab4 CS1050+Prelab+4 Concepts to Practic User-written functions Recursion For the prelab assignment, you are to write

Code in c image text in transcribed
image text in transcribed
.1 MetroPCS 8:08 PM 55% CS1050 Prelab4 CS1050+Prelab+4 Concepts to Practic User-written functions Recursion For the prelab assignment, you are to write recurs ve function to calculate Power (exponentiation). The Power function you write will raise a given double type number to a positive integer power. This function must use recursion to achieve its goal. You may NOT use any function from math.h such as powD The main() function in your program should: 1 Print a message welcoming the user to the Power Calculation Program 2. Prompt the user to enter a number that will be raised to a power. You should accept this as a double type number Prompt the user to enter a positive integer number representing the power. number less than 3 or greater than 300, print an error message and have the user re-enter the power number until you have a valid integer ranging from 1 to 100 3. If the user enters a 4. Use your PowerD function to calculate the given number raised to the eiven power, and print the result Prompt the user as to whether they would like to go through the process again, and repeat the process if so. not, exit the program S. Functions You Mlust Write You may weite any functions you wish to implement this program, in addition to the following functions However, you must implement the following functions * double Powerfdouble base, int exponent)-This function raises base to the power exponent and returns the result. The calculation must be done using recursion e int CheckPowertxponent[int exponent)-This function checks whether the given exponent is appropriately in the range 1 through 100 s not in range, return If the exponent is in range, return 1. the exponent Int exponent)-This function prompts the user for an exponent and reads in their response. it must use CheckPowerExponent() to determine if the entered exponent is legal As long as the entered exponent is not legal, it should prompt apain, read the response again, check again, etc. until eventually a legal exponent is entered. eint Continuelvoid)-This function should prompt the user as to whether they wish to run another power calculation or not If the user does with to run it again, returm 2. not, return Q int mainlvoid)-Of course, you need to write a main 1-2 of 2 Dashboard Calendar To Do Notifications Inbox ill MetroPCS 8:08 PM 55% CS1050 Prelab 4... Hints You should print double nnbers with %lf as the formatter. This will mean that you will get default precision (which may mean that very small numbers appear to be zero- that's ok). * Sample Output (bold and underline shows user input) Welcome to the Power Calculation Program Enter a base: 1.85 Please enter an exponent from 1 through 100: Please enter an exponent from 1 through 100: Please enter an exponent from 1 through 100: Please enter an exponent from 1 through 188: 1.eseeee raised to the 1ee power-131.s81258 Calculate another power (enter 1 for yes or 8 for no)? 1 Enter a base: 2 Please enter an exponent from 1 through 100: 2.800e0e raised to the 10 power 1824.868086 Calculate another power (enter 1 for yes or 8 for no)? 1 Enter a base: 9.2 Please enter an exponent from 1 through 100: 12 8.28e8e0 raised to the 18 power -8.8089ee Calculate another power (enter 1 for yes or 8 for no)? 1 Enter a base: 8.5 Please enter an exponent from 1 through 100: Please enter an exponent from 1 through 188 Please enter an exponent from 1 through 100: Please enter an exponent from 1 through 100:1 8.588e80e raised to the 1 power-e.5eeeee Calculate another power (enter 1 for yes or e for no)? Dashboard Calendar To Do Notifications Inbox

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

4. Devise an interview strategy from the interviewers point of view

Answered: 1 week ago