Home > Back-end >  An array as a function parameter problem!!!!!!
An array as a function parameter problem!!!!!!

Time:10-08

Today learned this
Then I think if it is how make average but the array length and n scores cannot use variable I find CTRL + z interruption on the Internet is a problem with the way but in the end the results

CodePudding user response:

Lowercase n not initialized

CodePudding user response:

Business, there is no fault tolerance, if n==0 does do, in the for are doing, there is no need to get outside a [0]

CodePudding user response:

Didn't see in the main function call function, according to the question should be read a subroutine array, calculate the average and return to the main function, the main function definition array and the value of the input array call a subroutine (incoming array) average value and print it out,

CodePudding user response:

reference 1st floor ggglivw response:
lowercase n't initialize

0 or so

CodePudding user response:

Which means that all your value to initialization, you haven't initialized sum, I think you can find yourself of the rest of the problem of

CodePudding user response:

reference CHXCHXKKK reply: 3/f
not seen in the main function call function, according to the question should be read a subroutine array, calculate the average and return to the main function, the main function definition and the value of the input array, the array call a subroutine (incoming array) average value and print it out,

Added for me... Or so

CodePudding user response:

reference 5 floor ggglivw reply:
means to you all the value of the initialization, you haven't initialized sum, I think you can find yourself of the remaining problems of

I tried to use before...

CodePudding user response:

Does may be useless, as long as there is the initial value, the last is not zero, the output can't be like that.

CodePudding user response:

Your demo pit themselves, want to input 100 grades, nor initializes the memory performance in front of the array, cannot little input a few to test

CodePudding user response:

references 9 f ggglivw response:
your demo pit themselves, to enter 100, the front does not initialize the result array, cannot little a few to test for input

I just want to if n is what to do and then got a 100 to lose a few with Ctrl + z interrupt output among every time is this

CodePudding user response:

Will not someone you want to work more, in this way the input, or agreement, or configuration, is the most important thing you do function interface, know the process of how to run, enter the secondary,

CodePudding user response:

If you want to ask n, n CodePudding user response:

The
refer to 12 floor CHXCHXKKK reply:
if you want to n, n

Just like in front of the elder brothers said to initialization,

For example: int a [N]={0}, N=0, sum=0;

CodePudding user response:

reference 13 floor CHXCHXKKK reply:
Quote: refer to 12 floor CHXCHXKKK reply:

If you want to ask n, n

Just like in front of the elder brothers said to initialization,

For example: int a [N]={0}, N=0, sum=0;


Let send code reference
 
# include & lt; Stdio. H>
# define N 100

Float business (float arr [], int n)
{
int i;
Float aver, sum=0;
for(i=0; i{
The sum +=arr [I];
}
Aver=sum/n.
Return aver.
}

Int main ()
{
Int I, n=0;
Float arr={0} [N], aver=0;
Printf (" require much personal average: \ n ");
The scanf (" % d ", & amp; n);
for(i=0; i{
Printf (" input the first % d personal achievement: \ n ", I + 1);
The scanf (" % f ", & amp; Arr [I]);
}

Aver=average (arr, n);
Printf (" average=% 2 f ", aver);

return 0;
}

CodePudding user response:

On the 14th floor CHXCHXKKK
reference response:
Quote: refer to the 13th floor CHXCHXKKK response:

Quote: refer to 12 floor CHXCHXKKK response:

If you want to ask n, n

Just like in front of the elder brothers said to initialization,

For example: int a [N]={0}, N=0, sum=0;


Let send code reference
 
# include & lt; Stdio. H>
# define N 100

Float business (float arr [], int n)
{
int i;
Float aver, sum=0;
for(i=0; i{
The sum +=arr [I];
}
Aver=sum/n.
Return aver.
}

Int main ()
{
Int I, n=0;
Float arr={0} [N], aver=0;
Printf (" require much personal average: \ n ");
The scanf (" % d ", & amp; n);
for(i=0; i{
Printf (" input the first % d personal achievement: \ n ", I + 1);
The scanf (" % f ", & amp; Arr [I]);
}

Aver=average (arr, n);
Printf (" average=% 2 f ", aver);

return 0;
}


Today for the first time to learn the outside the main function is to write a didn't want to know why can a finish to add a outside
  • Related