Help please! I'm writing the main part of a program that utilizes several functions (in various files); I think I've got the functions (like poly.c that's mentioned here) but I'm confused about this.
I don't know if my question makes any sense...
I am having trouble with the part about inputting the coefficients.
I use "printf" to ask the user to input the coefficients; but how many coefficients am I asking for? Also, do I use scanf to detect the coefficients? How can I use scanf if I don't know the number of coefficients that have to be inputted?)
Write a program that:
4.a) Reads a polynomial (p) from the keyboard using scanf. You should
prompt the user to enter the degree of the polynomial (d). If d < 0
you should exit the program. If d >= 0 prompt the user to input all
coefficients from 0 to d. Input here is from the terminal keyboard,
not a file!
4.b) Exit with an error message if the coefficient of the monomial
with the highest degree is zero.
4.c) Using the functions you wrote in poly.c:
4.c.i) Compute the first (p') and second (p'') derivatives of p;
4.c.ii) Print the polynomials p, p' and p'';
4.c.iii) Compute a zero (y) of p using Newton's method starting at x = 1;
4.c.iv) If a zero of p has been found, print the zero (y) and the value
of p(y);
If a zero has not been found issue a message;
HINT: Use the function isnan() to check for a NAN!
4.c.v) Compute a zero (z) of p' using Newton's method starting
at x = 1;
4.c.vi) If a zero of p' has been found, print the zero (z) and the
value of p'(z); If a zero has not been found issue a message;
HINT: Use the function isnan() to check for a NAN!
4.c.vii) Evaluate p''(z) and inform the user if z is a point of
maximum, minimum or inflection. As we are computing
approximate zeros, you should compare p''(z) not with zero
but a small number, say 1E-4.
4.c.viii) Destroy all polynomials you created during the execution of
your program and print the value of poly_memory() to ensure
it is zero.
Thank you!
BY THE WAY, here's what I have (it's pretty basic b/c I'm not sure what the prompt is asking me to do):
Code:
#include <stdio.h>
main()
{
int p, p', p'', d;
printf("Enter degree (d) of polynomial:\n");
scanf("%d", &d);
if (d>=0)
{
printf("Input all coefficients from 0 to d:\n");
int i;
for (i = 0; i < d; i++)
{
scanf(
}
/* code */
}else
{
if (d<0)
{
printf("ERROR! d<0\n");
return 0;
}
}