When I try to compile this, I get a warning:
Quote:
In function 'poly_diff':
poly.c:206: warning: comparison between pointer and integer
Code:void
poly_diff(int *d, double **p) {
/*
* poly_diff(int *d, double **p)
* differentiates the polynomial (d, p)
*
* Example:
*
* int d1 = 4;
* double *p1;
* p1 = poly_create(d1);
* // set polynomial to 1 - 2.5 x^2 - x^4
* p1[0] = 1; p1[2] = 2.5; p1[4] = -1;
* poly_diff(&d1, &p1);
*
* will set (d, p) to the polyomial - 5 x - 4 x^3.
*
* Be sure to handle the case when polynomial is a constant!
*/
/* WRITE YOUR CODE HERE */
int counter;
for(counter=0; counter<(*d); counter++){
if(counter==0){
*(*((p)+counter))=*(*((p)+(counter+1)));
}
if(counter==1){
(*(*((p)+counter)))=(*(*((p)+(counter+1))))*(dou
ble)2;
}
if(counter==2){
(*(*((p)+counter)))=(*(*((p)+(counter+1))))*(dou
ble)3;
}
if(counter==3){
(*(*((p)+counter)))=(*(*(((p)+(counter+1)))))*(d
ouble)4;
}
}
d=(d-1);
for(counter=0;counter<(d+1); counter++){
printf("%d ", *(p+counter));
}
}