That's much better - no spaces at end of line.
Is this a "find five faults competition" ? [That is a joke, I know it's definitely not easy as a beginner - which is why I'm posting some comments to help you fix it up]
Code:
void fill_arr(float farry[], int *size){
int fills = 0;
while (fills < *size && scanf(“%f”, &farry) !=EOF)
fills ++;
*size = fills;
}
}
You don't really want to update *size inside the loop and use it as a loop limit at the same time. I'd update *size when the loop is finished.
Code:
float ascend_arr(float aarry[]){
int ascend, sizearr;
float order;
int next = aarry[0];
for(ascend = 1; ascend < sizearr; ascend ++){
if (next < aary[ascend])
order = 1;
else
order = -1;
}
return (order);
}
As per my previous post: sizearr should be passed in, not a local variable - as it stands, it's going to crash your program, most likely - sooner or later at least.
Different name to the parameter into your function
I'm not entirely sure what the purpose of this function is - it returns 1 or -1 depending on the first and last entry.
Code:
float descend_arr(float darry[]){
int descend, sizearr;
float order;
int next = darry[0];
for(descend = 1; descend < sizearr; descend ++){
if (next > darry[descend])
order = 1;
else
order = -1;
}
return (order);
}
Same functionality as above - just different sign - so perhaps return "-ascend()"??
Code:
float power_func(float firsval, int seconval){
int count;
float powerval =0.0;
if (seconval < 0){
firsval = -1;
seconval= 1/seconval;
}
for(count = 0; count < seconval; count++){
powerval *= firsval;
}
return powerval;
}
I've already done this one in a previous post - please review that part.
Code:
float add_arr(float adarry[]){
int count, sizearr;
float sum = adarry[0];
for(count = 1; count < sizearr; count++){
sum += adarry[count];
}
return sum;
}
float subtract_arr(float subarry[]){
int count, sizearr;
float difference = subarry[0];
for(count = 1; count < sizearr; count++){
difference -= subarry[count];
}
return difference;
}
float multiply_arr(float multarry[]){
int count, sizearr;
float product = multarry[0];
for(count = 1; count < sizearr; count++){
product *= multarry[count];
}
return product;
}
float division_arr(float divarry[]){
int count, size;
float quotient = divarry[0];
for(count = 1; count < size; count++){
quotient /= divarry[count];
}
return quotient;
}
These all have the same problem with a "uninitialized local sizearr" - and you should really use the same name for same use variables, don't call it size in one place and sizearr in all the others - consistency is a VERY good thing in programming - it just makes everyones life much easier [and no, I don't always achieve it either].
--
Mats