- #1
clook
- 35
- 0
i need to get this array to calculate the numbers that are less than the average and greater than or equal to the average.
first of all, i need to figure out how to make a counter to count the average of the array! i can't find the code in the textbook
here's what i have so far:
first of all, i need to figure out how to make a counter to count the average of the array! i can't find the code in the textbook
here's what i have so far:
Code:
#include <stdio.h>
#define MAXARR 20
main()
{
int
arr[MAXARR], i, counter, value, no_of_elements, max,sum;
/*----------------------------------------------------------------------*/
/* User is requested to enter values from keyboard until -1 is entered */
/*----------------------------------------------------------------------*/
printf("\f");
counter = 0;
printf("Do not entere more than %d values\n\n",MAXARR);
printf("Enter value (-1 to quit): ");
scanf("%d", &value);
while (value != -1)
{
arr[counter]=value;
printf("Please enter value (-1 to quit): ");
scanf ("%d", value);
counter = counter + 1;
}
/*----------------------------------------------------------------------*/
/* Output routine. The number of elements entered is displayed */
/*----------------------------------------------------------------------*/
no_of_elements = counter;
printf("%d values were entered\n",no_of_elements);
printf("these values are: \n");
for(i=0;i<no_of_elements;i=i+1)
printf("%d ",arr[i]);