ProgIng - Programación en Ingeniería
Loading...
Searching...
No Matches
Ejemplo009.c File Reference
#include <stdio.h>
Include dependency graph for Ejemplo009.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 3 of file Ejemplo009.c.

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}