I've been hammering myself on to this homework for a while now. And I can't seem to find what's wrong with it.
My question is why do I keep getting segmentation fault errors everytime I execute this program.
/* Description: A program that takes an input array argument with type double values and displays a table of those inputs and their absolute values.
*/
...
int main() /* Main Function */
{
/* Variables */
int size=5,n;
double value[n];
double table;
/* Instructions and Input */
for(n=0;n<size;n++){
printf("\nPlease enter value #%d:\n",n);
if(n=size-1){printf("\nPlease enter the last value.\n");}
scanf("%lf",&value[n]);
}
/* Recalling the Function and Output */
printf("\nValue\t|Value|\n"); /* Table Header */
table=abs_table(value[n],size); /*Absolute Value Table */
return 0;
}
double abs_table(double value, int size) /* Absolute Value Function */
{
int i,j; /* Counter Variables */
double v;
for(j=1;j<=size;j++){ /* For the Number of rows */
for(i=0;i<=size;i++){ /* For the number of columns */
v = abs(value); // For the absolute values */
printf("\n%g\t%g\n",value,v);
}
printf("\n"); /* To make sure the rows display on their own line */
}
return;
}