my code has to meet this requirement "The total number of values greater than or equal to 128 in the array."
I am not sure how to how the code to find the total amount of number that is greater or equal to the value... can help would be appreciated.
Code:
#include <stdio.h>
#include <math.h>
#define m 5
#define n 6
int main(void)
{
int i, j,max, min, count=0 ;
double total = 0, total_sqr=0, st_dev;
int d[m][n] =
{
{15, 18, 30, 200, 234, 37},
{12, 134, 128, 190, 111, 124},
{77, 177, 130, 35, 64, 120},
{123, 234, 228, 190, 211, 12},
{78, 77, 13, 35, 164, 220}
};
int average;
max = d[0][0];
min = d[0][0];
for(i=0; i<m; i++)
for(j=0; j<n; j++)
{
count = 0;
total=total + d[i][j];
total_sqr = total_sqr + d[i][j]*d[i][j];
if (min >d[i][j])
min = d[i][j];
if (d[i][j]>max)
max = d[i][j];
if (d[i][j]>128)
count++;
}
average = (float)total/(float) (m*n);
st_dev = sqrt(total_sqr/(m*n)-average*average);
printf("the average is %d\n", average);
printf("the standard deviation is %.2f\n", st_dev);
printf("the minium value is %d\n", min);
printf("the maxium value is %d\n", max);
printf ("count = %d\n", count);
return 0;
}