ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo009.c
Go to the documentation of this file.
1
#include <stdio.h>
2
3
int
main
(
int
argc,
char
*argv[])
4
{
5
int
i, n, s;
6
long
den;
7
float
x, sx, num;
8
do
{
9
printf(
"Ingrese el numero de terminos: "
);
10
scanf(
"%d"
, &n);
11
}
while
(n<1);
12
printf(
"Ingrese el valor de x: "
);
13
scanf(
"%f"
, &x);
14
for
(i=0, num=x, den=1, sx=0; i<n; i++)
15
{
16
s = 1-2*(i%2);
17
sx += (s*num/den);
18
//printf("%d. %d %f %ld %f\n", i, s, num, den, sx);
19
num*=(x*x);
20
den*=((2*i+2)*(2*i+3));
21
}
22
printf(
"sin(%f) = %f\n"
, x, sx);
23
return
0;
24
}
main
int main(void)
Definition
Ejemplo_035.c:15
src
20252
Ejemplo009.c
Generated by
1.16.1