ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo010.c
Go to the documentation of this file.
1
30
31#include <stdio.h>
32
39int main(int argc, char *argv[])
40{
41 (void)argc;
42 (void)argv;
43
44 int n, i, j;
45 float x, fct, ex;
46
47 do {
48 printf("Ingrese el numero de terminos: ");
49 scanf("%d", &n);
50 } while (n < 1);
51
52 printf("Ingrese el valor de x: ");
53 scanf("%f", &x);
54
55 /*
56 Para cada i:
57 fct = x^i / i! calculado como producto:
58 fct = (x/1)*(x/2)*...*(x/i)
59 Luego:
60 ex += fct
61 */
62 for (i = 0, ex = 0; i < n; i++)
63 {
64 for (j = 0, fct = 1; j < i; j++)
65 fct *= (x / (j + 1)); /* multiplica por x/(j+1) */
66
67 ex += fct;
68 }
69
70 printf("exp(%f) = %f\n", x, ex);
71 return 0;
72}
double fct(double x, int n)
Definition Ejemplo029.c:34
int main(void)
Definition Ejemplo_035.c:15