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

Go to the source code of this file.

Macros

#define N   1000

Functions

float validar2 (float a, float min, float max, char *str)
float validar (float min, float max, char *str)
float asen (float x, int n)
int main (int argc, char *argv[])

Macro Definition Documentation

◆ N

#define N   1000

Definition at line 4 of file Ejemplo033.c.

Function Documentation

◆ asen()

float asen ( float x,
int n )

Definition at line 29 of file Ejemplo033.c.

30{
31 int i;
32 float asx, fct;
33 for(i=0, asx=0, fct=x; i<n; i++)
34 {
35 asx+=fct;
36 fct*=((2*i+1)*x*x/(2*i+3));
37 fct*=((2*i+1.0)/(2*(i+1)));
38 }
39 return asx;
40}
double fct(double x, int n)
Definition Ejemplo029.c:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

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

Definition at line 42 of file Ejemplo033.c.

43{
44 int n=0;
45 float x=-1, asx;
46 if(argc==3)
47 x = atof(argv[2]);
48 if(argc&2)
49 n = atoi(argv[1]);
50 n = (int)validar2(n, 1, N, "n");
51 x = validar2(x, -1, 1, "x");
52 asx = asen(x, n);
53 printf("asen(%f) = %f\n", x, asx);
54 return 0;
55}
#define N
float asen(float x, int n)
Definition Ejemplo033.c:29
float validar2(float a, float min, float max, char *str)
Definition Ejemplo033.c:6
Here is the call graph for this function:

◆ validar()

float validar ( float min,
float max,
char * str )

Definition at line 18 of file Ejemplo033.c.

19{
20 float a;
21 printf("Ingrese el valor de %s: ", str);
22 scanf("%f", &a);
23 if(a>min&&a<max)
24 return a;
25 else
26 return validar(min, max, str);
27}
#define max
#define min
float validar(float min, float max, char *str)
Definition Ejemplo033.c:18
Here is the call graph for this function:
Here is the caller graph for this function:

◆ validar2()

float validar2 ( float a,
float min,
float max,
char * str )

Definition at line 6 of file Ejemplo033.c.

7{
8 if(a>min&&a<max)
9 return a;
10 printf("Ingrese el valor de %s: ", str);
11 scanf("%f", &a);
12 if(a>min&&a<max)
13 return a;
14 else
15 return validar2(a, min, max, str);
16}
Here is the call graph for this function:
Here is the caller graph for this function: