Q:

C Program to Evaluate Polynomial using Horner’s method

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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 .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Number Solved Programs – C Programming

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program to find GCD (HCF) of Three Numbers using... >>
<< C Program to Find the Greatest Among Ten Numbers...