//###################################################################### // FILE : draw_poly_ohadbara.c // WRITER : ohad barak, 033800467 // EXERCISE : 1a // DESCRIPTION: the program reads the order of a polynom from standard // input ( the keyboard or a file ). // then it reads the polynom coefficients. // Next, it calculates the value ( the f(x) ) of the polynom // for every x between -10 and 10 and prints it to // standard output ( the screen or a file ). // INPUT FILE NAME: draw_poly_ohadbara.input // // EXAMPLE INPUT1: 3 17 -5 6 2 // EXAMPLE INPUT2: 3 // 17 // -5 // 6 // 2 // // both inputs are the same, as far as scanf is concerned. // The meaning of this input is a polynom of a 3rd order // that looks like this: // 17*x^0 -5*x^1 +6*x^2 +2*x^3 // // the output will be a long list of pairs of x and f(x): // . . // . . // . . // -0.029866 6.853291 // -0.019866 6.901836 // -0.009866 6.950958 // 0.000134 7.000668 // 0.010134 7.050978 // 0.020134 7.101900 // . . // . . // . . //###################################################################### #include int main() { int n; // order (haseder) of the polynom. int i; int *poly; // pointer to an array that will contain the polynom coefficients ( hamekadmim ). float sum; float x; scanf("%d", &n); // input the order of the polynom. n++; // think - why do we need to do this? poly = (int *) malloc(n*sizeof(int)); // allocate memory for the polynom array. for (i=0; i ex1a_output ). // and then we can draw the file using gnuplot. } }