SHOW:
|
|
- or go back to the newest paste.
1 | #include <stdio.h> | |
2 | main() | |
3 | { | |
4 | int num; | |
5 | - | printf("%lf",adverage(temperature,10000)); |
5 | + | double *junk; |
6 | double temperature[10000]; | |
7 | - | double adverage(double *p, int elements) |
7 | + | printf("Inserta un numero entero"); |
8 | scanf("%d",&num); | |
9 | junk=(double *) malloc (num * sizeof(double)); | |
10 | printf("%lf",average(junk,num)); | |
11 | free(junk); | |
12 | } | |
13 | double average(double *p, int elements) | |
14 | { | |
15 | double result=0; | |
16 | int i; | |
17 | for(i=0;i<elements;i++) | |
18 | { | |
19 | result+=*(p+i); | |
20 | } | |
21 | result/=(float) elements; | |
22 | return result; | |
23 | } |