Skip to content

Instantly share code, notes, and snippets.

@Yago
Created January 29, 2014 09:41
Show Gist options
  • Save Yago/86fabca8f60beaeec1fc to your computer and use it in GitHub Desktop.
Save Yago/86fabca8f60beaeec1fc to your computer and use it in GitHub Desktop.
C - Conditions
// Types de tests :
/*
SYMBOLE SIGNIFICATION
== est ?gal ?
> est sup?rieur ?
< est inf?rieur ?
>= est sup?rieur ou ?gal ?
<= est inf?rieur ou ?gal ?
!= est diff?rent de
&& ET
|| OU
! NON
*/
// Exemple :
int main(int argc, char *argv[])
{
int age = 20;
if (age >= 18){
printf ("Vous etes majeur !\n");
}else if (age >= 4){
printf ("Vous etes trop jeune !\n");
}else {
printf ("Vous etes trop vieux !\n");
}
return 0;
}
// Bolean ///////////////////////////////////
/* Augmente la lisibilit? du code
1 = True
0 = False
*/
int age = 20;
int majeur = 0;
majeur = age >= 18; // majeur = 1
if (majeur){
printf("Tu es majeur !");
}else {
printf("Tu es mineur");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment