1
Algorithmique et programmation 2
Chapitre 1:Rappel
Prof: R. EL AYACHI
1. Introduction
2. Variable, saisie, calcul, affichage
3. Structures alternatives
4. Structures itératives
MIPC: S3 Département d’Informatique
2
Un programme en c : un programme écrit en
langage c qui traduit un algorithme décrivant la
solution d’un problème.
• Il est composé de:
• Directives de préprocesseur (#)
• Déclarations
• Fonctions
• Fonction principale (main)
•Instruction
•Bloc
• Commentaires (/* texte*/ , // ligne)
Introduction
Prof: R. EL AYACHI MIPC: S3 Département d’Informatique
3
Introduction (suite)
Prof: R. EL AYACHI
#include<stdio.h>
float Rayon,Pi=3.14;
float Surface(float r)
{return(r*r*Pi);}
main()
{
float Res;
Scanf("%f",&Rayon);
Res =Surface(Rayon);/* Appel de la fonction*/
printf ("%f",Res);
}
Exemple:
Directive
Bibliothèque
Déclaration de données
Fonction
Fonction principale
Instruction
Bloc
Commentaire
MIPC: S3 Département d’Informatique
4
Donnée
Prof: R. EL AYACHI
Donnée: constituée de trois attributs
(identificateur, valeur et type)
• Mots réservés au langage c:
auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while
MIPC: S3 Département d’Informatique
5
Donnée (suite)
Prof: R. EL AYACHI
Type: Nom Taille
char 1 octet
int
short int
long int
unsigned int
2 octets (et plus)
2 octets
4 octets
2 octets
float
double
long Double
4 octets
8 octets
10 octets
Catégories de donnée: variable et constante
MIPC: S3 Département d’Informatique
1 / 28 100%