# Thread: don't understand an array in function program

1. ## don't understand an array in function program

Code:
```#include<stdio.h>
void round (int values[5][5]);
int keep (int num[5][5]);

void main(void){
int first[5][5];
int p, q;

for (p = 0; p < 5; ++p)
for (q = 0; q < 5; ++q)
first[p][q] = p+q;
round(first);
}

void round (int values[5][5]){
int u, v, t;
for (u = 0; u < 5; ++u)
for (v = 0; v < 5; ++v)
values[u][v] = values[u][v]%3;
t = keep(values);
printf("t = %i", t);
}

int keep (int num[5][5]){
int s, t, k = 0;
for (s = 0; s < 5; ++s)
for (t = 0; t < 5; ++t)
k += num[s][t];
return k;
}

i need some help getting this program.
it looks like
for (p = 0; p < 5; ++p)
for (q = 0; q < 5; ++q)
first[p][q] = p+q;
round(first);```
is putting each array number in the "round function" five times. and "first[p][q] = p+q;" makes each array a number? [0][1] = 1 [2][2] = 4 [3][2] = 5 etc?
but what's confusing me is in the round function this: values[u][v] = values[u][v]%3; is making each array the number it is modulus to 3??? and then t = the keep function
which also loops five times just adds the numbers and stores as k and returns it back to what t is. i'm not seeing how this compiles or prints t = 25 at the end at all. could
someone possibly run me through this?

2. main calls round just once, not 5 times.

Code:
```int /* Yes, really! */ main(void){
int first[5][5];
int p, q;

for (p = 0; p < 5; ++p) {
for (q = 0; q < 5; ++q) {
first[p][q] = p+q;
}
}
round(first);
return 0;
}```

3. Hm whydo i keep getting 19

4. Your program doesn't call rand(), and has no user input.
It's going to give you the same answer each time you run it.

Use a debugger to step through the code, so you can see things like
- when functions are called, and when they return
- when variables are modified.

Or you can add printf statements at each end of the function, like
Code:
```int keep (int num[5][5]){
int s, t, k = 0;
printf("Start of keep\n");
for (s = 0; s < 5; ++s)
for (t = 0; t < 5; ++t)
k += num[s][t];
printf("End of keep, return %d\n", k );
return k;
}```