Having this C code:
#include <stdlib.h>
#include <stdio.h>
long int sum(int n){
int m[n];
double sum = 0.0;
for(int i = 0; i < n; m[i] = rand(), sum += m[i], i++);
return sum;
}
int main(int argc, char ** argv){
printf("Rand sum: %ld", sum(8));
}
When I execute trying different arguments for the sum function, it always returns the same value even tough I'm am generating random numbers. If I print the generated numbers on each iteration, it indeed generates different values, but the sum is always getting the same result. These are some results given the argument value: n=8 -> sum=127071,n=6 -> sum=86235, n=10 -> sum=178497