ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo037.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <stdlib.h>
3
4
int
main
(
int
argc,
char
*argv[])
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
}
main
int main(void)
Definition
Ejemplo_035.c:15
src
20252
Ejemplo037.c
Generated by
1.16.1