Déclaration de fonctions avec Prototype


alain Adelmar

aadelmar@numericable.fr beuuh c est quoi ca

Trois exemples de fonctions avec Prototype


/*Déclaration de fonctions avec prototype, type de valeurs de retour, synthaxe*/

/* FICHIER ex_d3.c */
# include <stdio.h>
/* déclaration des fonctions */
double f (double a);     /* format long */
double g (double);    /* format court */
/* definition des fonctions */
doublef(doublea){
printf ("a = %f\t", a);
if (a<=0.01){
return(0.0);
}
else{
returng(a*2.0);
}
}
doubleg(doublex){
printf("x = %f\n",x);
/* syntaxe du if sans accolades */
if(x<=0.01)return(0.0);
elsereturnf(x/3.0);
}
/* programme principal */
voidmain(void){
f(10);
}
 

/*_____________________________________*/

/* déclaration des fonctions avec
* prototype, type de val de ret, nom, ces params
*/
doublef(doublea);/* format long */
doubleg(doublex);/* format court */

/* définition des fonctions */
doublef(doublea){
printf("a = %f\n",a);
if(a<=0.01){
return(0.0);
}
else{
returng(a*2.0);
}
}

doubleg(doublex){
printf("x = %f\n",x);
if(x<=0.01)return(0.0);
elsereturnf(x/3.0);
}
/* programme principal */
voidmain(void){
f(10);
}

/*________________________________________*/

/* prototype de la fonction g à l'interieur
* de f, (comme une variable):
*/

doublef(doublea){
doubleg(doublex);
printf("a = %f\n",a);
if(a<=0.01){
return(0.0);
}
else{
returng(a*2.0);
}
}
doubleg(doublex){
printf("x = %f\n",x);
if(x<=0.01)return(0.0);
elsereturnf(x/3.0);
}
voidmain(void){
f(10);
}

_________________________________________
                                                                                      retour en haut


index.html >> programmation >> langage C >> exemple