# Thread: Find the total number of value greater or equal to a number in a 2D array.

1. ## Find the total number of value greater or equal to a number in a 2D array.

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;

}```

2. OK I see it:

LOOK what you are doing with your count var.
what happens to it every time you go into that
for loop....

3. Why is your program doing all those other calculations that have nothing to do with the problem description?

4. all the other calculations are for other parts of my program. the one in the description is the one im stuck on

5. Im not sure what you mean.... what am i suppose to do ?

6. locaicalization

Code:
``` for(j=0; j<n; j++)
{
// what happens to the value each time it goes into this for loop?

count = 0;

printf("My value is --> %d\n", count);

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++;
printf("Now my value is --> %d\n", count);

}```
basic trouble shooting printf 's

7. Sorry, I think my post was not that helpful so I deleted it.