# Demo entry 6326275

Teste

Submitted by teste on Nov 22, 2016 at 22:32
Language: C. Code size: 1.1 kB.

```#include <stdio.h>

void fibonacci(int array[100]){
int first = 0;
int second = 1;
int temp, i = 1;
array[i-1] = second;
while(i<100){
i++;
temp = second;
second = first + second;
first = temp;
array[i-1] = second;
//printf("%i\n", second);
}
}
void fibonacciV2(int array[100]){
int i;
for(i = 0; i < 100; i++){
if(i < 2){
array[i] = 1;
//printf("%d\n", array[i]);
} else {
array[i] = array[i-2] + array[i-1];
//printf("%d\n", array[i]);
}
}
}
void fibonacciV3(int array[100]){
int i;
array[0] = 1;
array[1] = 1;
for(i = 2; i < 100; i++){
array[i] = array[i-2] + array[i-1];
//printf("%d\n", array[i]);
}
}

float media(int array[100]){
float soma = 0.0;
int i;
for(i=0; i<100; i++){
soma += array[i];
}
return soma/100.0;
}

int main(){
int array[100];
int arrayV2[100];
int arrayV3[100];

fibonacci(array);
fibonacciV2(arrayV2);
fibonacciV3(arrayV3);

printf("Media = %f\n", media(array));
printf("Media = %f\n", media(arrayV2));
printf("Media = %f\n", media(arrayV3));
}
```

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.