#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
|
| int | main (int argc, char *argv[]) |
◆ main()
| int main |
( |
int | argc, |
|
|
char * | argv[] ) |
Definition at line 4 of file Ejemplo037.c.
5{
6 double *x, m;
7 int n, i;
8 do{
9 printf("Ingrese el numero de elementos: ");
10 scanf("%d", &n);
11 }while(n<1);
12 x = (double*)malloc(n*sizeof(double));
13 if(x==NULL)
14 return 1;
15 for(i=0, m=0; i<n; i++)
16 {
17 printf("x[%d] = ", i+1);
18 scanf("%lf", x+i);
19 m += x[i];
20 }
21 m/=n;
22 printf("Media = %lf\n", m);
23 free(x);
24 return 0;
25}