Hey guys, I've got a similar problem here. I'm trying to make a program to calculate a polyonym but I'm getting an error. Here's the code:
Code:
#include <stdio.h>
#include <stdlib.h>
#define epsilon = 0.0001;

int p_grade, p_2nd, p_1st, p_zero, i, *p;
float x1,x2,x_0, err, x_mid;

float force (float x, int y)
{
int i, j=1;
for (i=1; i < y; i++) j*=x;
return j;
}

float f (int x)			/*Ορισμός συνάρτησης πολυωνύμου*/
{
int i, j=0;
return j;
}								/*Τέλος ορισμού*/
float root (float a, float b)
{
float f1, f_mid, x_mid, err;
f1 = f(a);
if (f(f1*(f(b)))>0) err = 1.0;
else
{
err = 0;
x_mid = (a+b)/2;
while (abs(a - x_mid) > epsilon)
{
f_mid = f(x_mid);
if ((f1 * f_mid) <= 0) b = x_mid;
else
{
a = x_mid; f1 = f_mid;
}
x_mid = (a+b)/2;
}
}	return x_mid;
}
void main()
{
printf("ΒΑΘΜΟΣ ΠΟΛΥΩΝΥΜΟΥ?:");  scanf("%d", &p_grade);	/* Εισαγωγή των δεδομένων της άσκησης*/
p = (int *) malloc(p_grade * sizeof (int));
if (p == NULL)
{

}
else
{

}
for (i = p_grade; i >= 0; i--) {printf("ΣΥΝΤΕΛΕΣΤΗΣ ΟΡΟΥ i?:"); scanf("%d", &p[i]);}

printf("Η ΤΙΜΗ Χ1 είναι?:"); 	scanf("%f", &x1);
printf("Η ΤΙΜΗ Χ2 είναι?:"); 	scanf("%f", &x2); 	/*Τέλος της εισαγωγής*/
free(p);
}
I get that output:
Code: