Created
January 29, 2014 09:38
-
-
Save Yago/1f8f70d837ed0d3349b6 to your computer and use it in GitHub Desktop.
C - Variables
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 | |
unsigned char 0 255 | |
unsigned int 0 65 535 | |
unsigned long 0 4 294 967 295 | |
*/ | |
// Exemples : | |
int nombreDeVies; | |
nombreDeVies = 5; | |
ou | |
int nombreDeVies = 5; | |
int nombreDeVies = 5, niveau = 1; | |
const int NOMBRE_DE_VIES_INITIALES = 5; // Constante | |
// Afficher une variable ////////////////////////////////////////////////// | |
/* | |
FORMAT TYPE ATTENDU | |
"%d" int | |
"%ld" long | |
"%f" float | |
"%f" double | |
"%c" char (une lettre) | |
"%s" char (string) | |
*/ | |
// Exemples : | |
printf("Il vous reste %d vies", nombreDeVies); | |
printf("Vous avez %d vies et vous etes au niveau n? %d\n", nombreDeVies, niveau); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment