INFO505 Programmation C
Loading...
Searching...
No Matches
TP1
fct.c
1
#include <stdlib.h>
2
#include <math.h>
3
#include <stdio.h>
4
5
float
f(
float
x )
6
{
7
return
sqrt( x ) * sin( x );
8
}
9
10
void
usage()
11
{
12
printf(
"fct [debut] [fin] [pas]\n"
);
13
printf(
"- Calcule les valeurs d'une fonction entre [debut] et [fin] par pas de [pas].\n"
);
14
}
15
16
int
main(
int
argc,
char
** argv )
17
{
18
float
debut, fin, pas;
19
20
if
( argc < 4 )
21
{
22
usage();
23
return
0;
24
}
25
debut = atof( argv[ 1 ] );
26
fin = atof( argv[ 2 ] );
27
pas = atof( argv[ 3 ] );
28
29
while
( debut <= fin )
30
{
31
printf(
"%f %f\n"
, debut, f( debut ) );
32
debut += pas;
33
}
34
return
0;
35
}
Generated on Wed Nov 8 2023 11:06:18 for INFO505 Programmation C by
1.9.8