A POLYNOMIAL IS A FUNCTION WHICH IS FORMED BY THE COMBINATION OF VARIABLES AND CONSTANTS OR SOLELY VARIABLES...
IT MAY BE OF MANY TYPE , IT MAY CONTAIN MORE THAN ONE VARIABLE ALSO AND ETC.
A POLYNOMIAL IS GENERALLY DENOTED BY "f(x)" OR "p(x)" OR "f(x,y)" ETC..
HERE WE ARE DEALING WITH ONLY ONE VARIABLE i.e "x" .
HERE IS A C PROGRAM TO FIND THE SUM OF A POLYNOMIAL GIVEN BELOW :
f(x) = ax^n + bx^(n-1) + cx^(n-2) + .......
The program will demand user to enter the value of "x" and will automatically print the necessary output....
#include<conio.h>
void main()
{
int sum=0,x,a[20];
int i,n;
printf("Enter the number of coefficient \n");
scanf("%d",&n);
printf("Enter the %d polynomial(s)\n",n+1);
for(i=0;i<=n;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the value of x \n");
scanf("%d",&x);
sum=a[n]*x;
for(i=n-1;i>0;i--)
{
sum=(sum+a[i])*x;
}
sum=sum+a[0];
printf("The sum = %d \n",sum);
getch();
}
IT MAY BE OF MANY TYPE , IT MAY CONTAIN MORE THAN ONE VARIABLE ALSO AND ETC.
A POLYNOMIAL IS GENERALLY DENOTED BY "f(x)" OR "p(x)" OR "f(x,y)" ETC..
HERE WE ARE DEALING WITH ONLY ONE VARIABLE i.e "x" .
HERE IS A C PROGRAM TO FIND THE SUM OF A POLYNOMIAL GIVEN BELOW :
f(x) = ax^n + bx^(n-1) + cx^(n-2) + .......
The program will demand user to enter the value of "x" and will automatically print the necessary output....
THE PROGRAM IS :
#include<stdio.h>#include<conio.h>
void main()
{
int sum=0,x,a[20];
int i,n;
printf("Enter the number of coefficient \n");
scanf("%d",&n);
printf("Enter the %d polynomial(s)\n",n+1);
for(i=0;i<=n;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the value of x \n");
scanf("%d",&x);
sum=a[n]*x;
for(i=n-1;i>0;i--)
{
sum=(sum+a[i])*x;
}
sum=sum+a[0];
printf("The sum = %d \n",sum);
getch();
}
Just copy and paste into your Microsoft Visual C++ or Turbo C (these are program developing software)
Or else you can try this demo file and use it to find the sum of a polynomial ...
Click HERE to download this file.
~NOTE~ : While executing if you get any warning then just ignore it and continue with your program...
Click HERE to download this file.
~NOTE~ : While executing if you get any warning then just ignore it and continue with your program...
IF FACE ANY PROBLEM DON'T FORGET TO COMMENT ...!!
No comments:
Post a Comment