Using a for loop to input and output array values Also calculate the average

I have this code that im stuck on what i need to do is Extend the code such that when it starts the user is asked to input values to specify each of the three ranges before moving on to accept and tally the main values how do i do that
Using a for loop to input and output array values
Also calculate the average
*/

#include <stdio.h>


int main(void)
{
/* Declare an array of integers */
int Grades[5];
int nCount;
int nTotal = 0; /* Declare and initialise the value */
float fAverage;

/* Populate the array */
for(nCount = 0; nCount < 5; nCount++)
{
printf("\nPlease enter a value for array element %d : ",nCount);
scanf("%d",&Grades[nCount]);
nTotal += Grades[nCount];
}

printf("\n\n"); /* Just a couple of lines to add a gap */

/* Display the array */
for(nCount = 0; nCount < 5; nCount++) /* Note that reusing nCount */
{
printf("Array element %d has the value %d\n", nCount, Grades[nCount]);
}

/* Calculate the average */
fAverage = nTotal / 5;

/* Output the average grade */
printf("\nThe average grade value is %f", fAverage);

return 0;
}
Do you want help in C, or in C++? You have posted on a C++ forum but this code seems to be written exclusively in C.
C++ im using a dev c++ program and was told it was c++
closed account (iAk3T05o)
download code::blocks or visual c++ express
What exactly are you stuck on?
The program looks fine in that it takes the five values and calculates the average. Does it execute properly?

To extend the program, can't you just print the input request, accept the input, and then use it as appropriate, which is something you have already done?

What do you mean "each of the three ranges"?
im not sure what the three ranges are ive just started on learning programming and stuff and when i go to run it the value i always get is 0 :? sorry about this im not very experienced on this
Topic archived. No new replies allowed.