Grumpy, Citizen and Dave thank you for your help and information about the topic. I went away and came up with some code which worked fine until recently , but now all of a sudden stopped spitting out the 10 numbers I have inputted. I have no idea why it stopped working . The function correctly identifies the largest number , but the procedure ill not spit out the 10 values. I would appreciate if someone can take a look :
Code:
#include <stdio.h>
FILE * output =NULL;
FILE * input =NULL;
float function_maximum(float array[10]) //Function that works out the largest number
{
int i;
float maximum_number=0;
for(i=0; i<10; i++)
{
if(array[i]>maximum_number)
{
maximum_number=array[i];
}
}
fprintf(output,"The largest number entered is %E",maximum_number);
}
void print_array(float array[10]) // Procedure to print out the array contents
{ // Initiate a variable j to go through the array contents
int i;
for(i=0; i<10; i++)
{
fprintf(output,"%.4f\n ",array[i]); // Prints out the array values, numbers with 4 decimal places
}
}
int main(void)
{
int i;
int where_up_to=1;
float array[10];
output = stdout;
input = stdin;
for(i=0; i<10; i++) // For loop will fetch 10 values from the user
{
if(where_up_to==1) // This will add a correct suffix based on where the loop is up to.
{
fprintf(output,"Enter %dst value\n" ,where_up_to);
fscanf(input,"%d",&array[i]);
where_up_to=where_up_to+1;
}
else if((where_up_to==2)||(where_up_to==3))
{
fprintf(output,"Enter %dnd value\n" ,where_up_to);
fscanf(input,"%d",&array[i]);
where_up_to=where_up_to+1;
}
else
{
fprintf(output,"Enter %dth value\n" ,where_up_to);
fscanf(input,"%d",&array[i]);
where_up_to=where_up_to+1;
}
}
print_array(array);
function_maximum(array);
}
Once again , thank you for all your help .