Algorithmique et Langage - Pages de Michel Deloizy - Free
Algorithmique et Langage - Pages de Michel Deloizy - Free
Algorithmique et Langage - Pages de Michel Deloizy - Free
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
somme(int<br />
a, int b)<br />
{<br />
int s;<br />
s=a+b;<br />
r<strong>et</strong>urn s;<br />
}<br />
Type <strong>de</strong> la fonction est omis → int<br />
double pi(void<br />
void)<br />
{<br />
double x;<br />
x=atan<br />
atan(1.0)*4;<br />
r<strong>et</strong>urn x;<br />
}<br />
Fonction non déclarée → int<br />
Ici : inclure math.h<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
25<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
26<br />
Prototype<br />
! Perm<strong>et</strong> d'indiquer :<br />
! le type <strong>de</strong> donnée r<strong>et</strong>ourné par une fonction<br />
! le nombre <strong>et</strong> le type <strong>de</strong>s arguments transmis.<br />
# Déclaration <strong>de</strong> fonction.<br />
Exemples <strong>de</strong> prototype :<br />
double sin(double);<br />
double somme(double a, double b);<br />
Blocs d’instructions<br />
! Constitué :<br />
! d'une instruction élémentaire terminée par un<br />
caractère ";"<br />
ou<br />
! d'un ensemble d'instructions élémentaires encadrées<br />
par <strong>de</strong>s accola<strong>de</strong>s ; dans ce cas, le bloc d'instructions<br />
peut comporter <strong>de</strong>s déclarations (locales à ce bloc).<br />
ou<br />
! d'un simple caractère ';'.'<br />
'. Dans ce cas, l'instruction est<br />
vi<strong>de</strong> (sans eff<strong>et</strong>).<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
27<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
28<br />
7