ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo011.c
Go to the documentation of this file.
1
35
36
#include <stdio.h>
37
44
int
main
(
int
argc,
char
*argv[])
45
{
46
(void)argc;
47
(void)argv;
48
49
int
n, i;
50
float
x,
fct
, ex;
51
52
do
{
53
printf(
"Ingrese el numero de terminos: "
);
54
scanf(
"%d"
, &n);
55
}
while
(n < 1);
56
57
printf(
"Ingrese el valor de x: "
);
58
scanf(
"%f"
, &x);
59
60
/*
61
Inicialización:
62
fct = t_0 = 1
63
ex = 0
64
65
En cada iteración i:
66
ex += fct (acumula t_i)
67
fct *= x/(i+1) (convierte t_i en t_{i+1})
68
*/
69
for
(i = 0, ex = 0,
fct
= 1; i < n; i++)
70
{
71
ex +=
fct
;
72
fct
*= (x / (i + 1));
73
}
74
75
printf(
"exp(%f) = %f\n"
, x, ex);
76
return
0;
77
}
fct
double fct(double x, int n)
Definition
Ejemplo029.c:34
main
int main(void)
Definition
Ejemplo_035.c:15
src
20261
src
Ejemplo011.c
Generated by
1.16.1