Created
January 29, 2014 09:41
-
-
Save Yago/86fabca8f60beaeec1fc to your computer and use it in GitHub Desktop.
C - Conditions
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 ? | |
!= 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