C Program to Evaluate Polynomial using Horner’s method

By | 05.11.2016

Evaluate Polynomial using Horner’s method


Write a C Program to Evaluate Polynomial using Horner’s method. Here’s simple C Program to Evaluate Polynomial using Horner’s method in C Programming Language.


Numbers in C


Normally, when we work with Numbers, we use primitive data types such as int, short, long, float and double, etc. The number data types, their possible values and number ranges have been explained while discussing C Data Types.


Here is source code of the C Program to Evaluate Polynomial using Horner’s method. The C program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.


SOURCE CODE : :


/*  C Program to Evaluate Polynomial using Horner’s method  */

#include <stdio.h>

int main()
{
     float a[100],sum=0,x;
     int n,i;

     printf("\nEnter degree of the polynomial X :: ");
     scanf("%d",&n);
     printf("\nEnter coefficient's of the polynomial X :: \n");
     for(i=n;i>=0;i--)
     {
            printf("\nEnter Coefficient of [ X^%d ] :: ",i);
            scanf("%f",&a[i]);
     }

     printf("\nEnter the value of X :: ");
     scanf("%f",&x);

     for(i=n;i>0;i--)
     {
        sum=(sum+a[i])*x;
     }

     sum=sum+a[0];

     printf("\nValue of the polynomial is = [ %f ]\n",sum);

     return 0;
}

Output : :


/*  C Program to Evaluate Polynomial using Horner’s method  */

Enter degree of the polynomial X :: 3

Enter coefficient's of the polynomial X ::

Enter Coefficient of [ X^3 ] :: 1

Enter Coefficient of [ X^2 ] :: 3

Enter Coefficient of [ X^1 ] :: 2

Enter Coefficient of [ X^0 ] :: 5

Enter the value of X :: 4

Value of the polynomial is = [ 125.000000 ]

Process returned 0

Above is the source code for C Program to Evaluate Polynomial using Horner’s method which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.


Thanks for reading the post….

5 2 votes
Article Rating
Category: C Programming Number Programs Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
yashu

its good bro but i am under stand the logic