Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

0. A Math Library functions, simple recursions (5pt) Specification Write an ANSI-C program that reads input from the standard input, which contains one double and

image text in transcribed

0. A Math Library functions, simple recursions (5pt) Specification Write an ANSI-C program that reads input from the standard input, which contains one double and one integer representing a base b and exponent (i.e., power) n, and then calculates b. After reading base and exponent from the user, the program first calls the math library function pow(), and then call function my_pow(), which is a recursive function that you are going to implement here. The program keeps on prompting user and terminates when user enters -1000 for base (followed by any number for exponent). Implementation Download file labSpow.c and start from there. Note that to read a double using scanf, we need to use $11. (is use for float). Your function my_pow(double, double) should be RECURSIVE, not ITERATIVE. That is, the function should be implemented using RECURSION, not loops. In a recursive solution, the function calls itself with different (usually smaller) inputs, until the input becomes small enough so that we can solve the case directly. This case is called a base case. Note that although the function's parameters are of type double, the actual argument for exponent is assumed to be an integer literal (i.e. the power will not be 3.5). However, the power can be negative. Your functions should handle this. Sample Inputs/Outputs red 1174 a.out Enter base and power: 10 2 pow: 100.0000 my_pow: 100.0000 Enter base and power: 10 4 pow: 10000.0000 my_pow: 10000.0000 Enter base and power: 2 3 pow: 8.0000 my_pow: 8.0000 2 Enter base and power: 2.35 pow: 64.3634 my_pow: 64.3634 Enter base and power: -2 4 pow: 16.0000 my_pow: 16.0000 Enter base and power: -2.75 5 pow: -157.2764 my_pow: -157.2764 Enter base and power: 2 - 3 pow: 0.1250 my_pow: 0.1250

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 Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago