ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 4 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 9.00

define a recursive function that computes xn

See attachment for question: 

Which of the following function definition will correctly define a recursive function that computes xn, using the formula x0 = 1 and xn = x * xn–1  

1)

int  power(double x, int n)

{

            if(n==0)

                        return 1;

            else

                        return x* x ^(n-1);

}

 

2)

int  power(double x, int n)

{

            if(n==0)

                        return 1;

            else

                        return x*power (x, n-1);

}

 

Both 1 and 2 will work
Neither 1 nor 2 will work
2 only
1 only

 

 

Attachments:

Answers

(11)
Status NEW Posted 22 May 2017 02:05 AM My Price 9.00

-----------

Not Rated(0)