The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 4 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
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: