This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printf("Hello world!\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Ci-dessous, ce sont des directives de préprocesseur. | |
Ces lignes permettent d'ajouter des fichiers au projet, | |
fichiers que l'on appelle bibliothèques. | |
Grâce à ces bibliothèques, on disposera de fonctions toutes prêtes pour afficher | |
par exemple un message à l'écran. | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Types variables ////////////////////////////////////////////////// | |
/* | |
TYPE MIN MAX | |
char -127 127 | |
int -32 767 32 767 | |
long -2 147 483 647 2 147 483 647 | |
float -1 x1037 1 x1037 | |
double -1 x1037 1 x1037 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int age = 0; // Variable contenante | |
scanf("%d", &age); // Dois taper son age stock? dans la variable | |
// Exemple : | |
int main(int argc, char *argv[]) | |
{ | |
int age = 0; // On initialise la variable ? 0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Op?rations simples possibles /////////////////////////////////////////////////// | |
/* | |
+ addition | |
- soustraction | |
* multiplication | |
/ division | |
% modulo => Reste dans un division entre entier relatif (ex : 8/3=2 reste 0.66666) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable++; // + 1 | |
variable--; // -1 | |
variable *= 2; // * 2 | |
variable -= 4; // - 4 | |
variable /= 4; // / 4 | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Types de tests : | |
/* | |
SYMBOLE SIGNIFICATION | |
== est ?gal ? | |
> est sup?rieur ? | |
< est inf?rieur ? | |
>= est sup?rieur ou ?gal ? | |
<= est inf?rieur ou ?gal ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If/else /////////////////////////////////// | |
if (age == 2){ | |
printf("Salut bebe !"); | |
}else if (age == 6){ | |
printf("Salut gamin !"); | |
}else if (age == 12){ | |
printf("Salut jeune !"); | |
}else if (age == 16){ | |
printf("Salut ado !"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if/else : | |
if (majeur){ | |
age = 18; | |
}else { | |
age = 17; | |
} | |
// Ternaire |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// While ////////////////////////////////////////////////////////////////// | |
/* while = tant que */ | |
int nombreEntre = 0; | |
while (nombreEntre != 47){ // Tant que l'utilisateur ne tape pas 47 | |
printf("Tapez le nombre 47 ! "); | |
scanf("%d", &nombreEntre); | |
} |
OlderNewer