INFO505 Programmation C
Loading...
Searching...
No Matches
fct.c
1#include <stdlib.h>
2#include <math.h>
3#include <stdio.h>
4
5float f( float x )
6{
7 return sqrt( x ) * sin( x );
8}
9
10void 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
16int 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}