Question: Develop a new function (RunningAvg()). This function will return the current average of the numbers which have been evaluated each cycle. A new local identifier

Develop a new function (RunningAvg()). This function will return the current average of the numbers which have been evaluated each cycle. A new local identifier in main() will retain the result from the function. The function call is to be done in one of the loops, you figure it out, and why else would it be called a running average instead of the averageJ <\ hint: hand calculate the average of the numbers in the array. That will be you ending average. Each running average does not need to be in a particular sequence, but the running average after two cycles is 8 /hint>

Do not use any global defined identifiers. The resulting values in the array m will be in descending order.

*/

main() { char wait; short m[]={3,5,7,2,5,1,2,2, 6,5,7,2,4,1,3,3, 7,7,3,2,5,7,1,9}; unsigned char temp, i, j; unsigned char numElements = sizeof(m)/sizeof(m[0])-1;

for (i=0; i<=numElements-1; i++) // change < to <= { for(j=i+1; j<=numElements; j++) // change < to <= { if ( m[i] <= m[j]) { temp = m[i]; //was m[j] should be m[i] m[i] = m[j]; m[j] = temp; } } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!