I have a problem that is, when I sum the values of an array (that are all positive, I verified by printing the values of the array), I end up with a negative value. My code for
I think your final output is going out of range. For this you will have to declare summcp as long long int
summcp
long long int
long long int summcp = 0; for (k = 0; k < SIMUL; k++) { summcp += mcp[k]; } printf("summcp: %lld.\n", summcp);
int variable throws garbage value if its range is exceeded.
int