Horners method - c program, Public Economics

Horners method -  C program:

Modify the program to implement the details for the recursive function called horners(double b, int n) that calculates Horner's method for a coefficient of 1 and a given value of b and for integer n. Horner's method for this problem is define as 1 + b * (1 + b * (1 + b * ( 1 + . . . + b))).

#include

#include

#include

#include

using namespace std;

double horners(double b, int n);

int main(int argc, char **argv)

{

             cout << "horners(2, 4)  = " << horners(2, 4) << endl;

             cout << "horners(3, 2)  = " << horners(3, 2) << endl;

             cout << "horners(5, 5)  = " << horners(5, 5) << endl;

             cout << "horners(10, 3) = " << horners(10, 3) << endl;

             cout << "horners(13, 2) = " << horners(13, 2) << endl;

             cout << endl << "Press any key to continue." << endl;

            getchar();

   return 0;

}

double horners(double b, int n)

{

   //     using recursive definition

  //       1 + b * (1 + b * (1 + b * ( 1 + . . . + b)));   

    return 0.0;

}

/*

Output will be

horners(2, 4) = 31

horners(3, 2) = 13

horners(5, 5) = 3906

horners(10, 3) = 1111

horners(13, 2) = 183

Posted Date: 2/11/2013 5:46:17 AM | Location : United States







Related Discussions:- Horners method - c program, Assignment Help, Ask Question on Horners method - c program, Get Answer, Expert's Help, Horners method - c program Discussions

Write discussion on Horners method - c program
Your posts are moderated
Related Questions

How has public policy helped to shape the way that urban Americans have spent their leisure time throughout the period that we have examined in class? Have such policies hindered a

Part I. We have examined federal public policies in the context of the democratic political system in the US.     Types of policy legislation/behavior fall into 3 main types. A

Our economic systems are of this type and share for general properties. a) Dissipative systems transform energy and process information to maintain a state of organization that

This question considers the possibility of foreign aid in exchange for favors. Suppose nation A has RA resources in its treasury and nation B has RB resources. The winning coalitio

Explain how the price system answers the five fundamental questions of economics, and talk about at least two of the short-comings of the capitalist price and market system.

Consider a case, if an insurance company merges with a bank. We know that insurance company bears risk for insurers. Suppose, after merger, bank gets in some trouble for reasons ot

explanation and justify the condition of pareto optimality and verify the defination of contrect curve. statment; reallocation of the resources from 1 efficient point to another ef

In the wake of the Asian financial crisis, policymakers, governments, and academics around the world are busy devising ways to reform the global financial architecture. The plethor

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4