-
Notifications
You must be signed in to change notification settings - Fork 4
/
26_0funciones-argumentos.c
46 lines (31 loc) · 993 Bytes
/
26_0funciones-argumentos.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
El uso de funciones aumenta la velocidad del programa.
En este programa usaremos las llamadas funciones en linea.
Aunque su nombre no adecuado ya que el preprocesador expande o
sustiye la expresion cada vez que es llamada.
El compilador inserta el codigo en el
punto en que esta funcion en linea o macros con argumentos se llama.
*/
/*
En estas lineas definimos la funcion creada por el usuario. La forma general es:
#define NOMBRE_MACRO(parametros_NO_tipo) expresion-texto
*/
/*
El ejercicio del estudiante consiste en implementar, al menos, cinco funciones en línea y
posteriormente, implementarlas como funciones creadas por el usuario.
*/
#include <stdio.h>
#define fesp(x) (x*x +2*x - 1)
void main(){
float x;
for (x =0.0; x<= 6.5; x +=0.5)
{
printf("f(%.1f) = %6.2f\n", x, fesp(x));
}
}
/*
El problema con este tipo de macros es que se consume
mucha memoria ya que la toda invocacion del macro
representa una copia de la expresion completa que
representa.
*/