funguje
This commit is contained in:
parent
d7626c5517
commit
5f89a7763e
BIN
du3/program
BIN
du3/program
Binary file not shown.
@ -1,15 +1,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
//#include<conio.h>
|
||||||
|
|
||||||
int main()
|
/*int main()
|
||||||
{
|
{
|
||||||
float a[100],sum=0,x;
|
float a[100],sum=0,x;
|
||||||
int n,i;
|
int n,i;
|
||||||
printf("\nEnter the value of X :: ");
|
printf("\nEnter the value of X :: ");
|
||||||
scanf("%f",&x);
|
scanf("%f",&x);
|
||||||
printf("\nEnter degree of the polynomial X :: ");
|
// printf("\nEnter degree of the polynomial X :: ");
|
||||||
scanf("%d",&n);
|
//scanf("%d",&n);
|
||||||
printf("\nEnter coefficient's of the polynomial X :: \n");
|
printf("\nEnter coefficient's of the polynomial X :: \n");
|
||||||
for(i=n;i>=0;i--)
|
for(i=n;i>=0;i--)
|
||||||
{
|
{
|
||||||
@ -27,4 +28,34 @@ int main()
|
|||||||
printf("\nValue of the polynomial is = [ %f ]\n",sum);
|
printf("\nValue of the polynomial is = [ %f ]\n",sum);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
int degree,x;
|
||||||
|
int coeff[10], i;
|
||||||
|
int sum = 0;
|
||||||
|
|
||||||
|
// Getting the degreee of the polynomial
|
||||||
|
printf("\nEnter the degree of the polynomial: ");
|
||||||
|
scanf("%d",°ree);
|
||||||
|
|
||||||
|
// Getting the coefficients of all terms of the polynomial
|
||||||
|
printf("\nEnter the coeffients from lower order to higher order: \n");
|
||||||
|
for(i=0; i<=degree; i++) {
|
||||||
|
scanf("%d",&coeff[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getting the value of the variable
|
||||||
|
printf("\nEnter the value of x: ");
|
||||||
|
scanf("%d",&x);
|
||||||
|
|
||||||
|
// Applying Horner's rule
|
||||||
|
sum = coeff[degree];
|
||||||
|
for(i=degree-1; i>=0; i--) {
|
||||||
|
sum = sum*x + coeff[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Printing result
|
||||||
|
printf("\nResult: %d",sum);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user