1. Variable type variable name; int score; 2. Assignment of variables score = 100; Score = A; Score = b = 100; 3. The output of the variable int a = 200; printf ("%i", a); Common format characters: 1>%d\%i integer (int) 2>%f decimal (float, double) 3>%c character (char) sample code
1: int main ()
2: {
3: / *
4: int score;
5: //assignment operation (initialization)
6: score = 1000;
7:
8: score = 10000;
9:
Ten: char c;
11:
: ' A ';
13:
Int. : int a = 20;
15:
16:
: //int d,e,f;
18:
: int b;
20:
: b = a = 40;
22:
At : b = 30;*/
24:
+//variable: As long as there is an indeterminate data, you should define the variable to save
: int score = 205;
: //1:15
: int time = 75;
29:
: int bestscore = 3161;
31:
+ : //%d\%i is a format character (placeholder) and can only output integers
: printf ("score is%d\n", score);
34:
35:
: float height = 1.78f;
37:
Number : //%f used to output decimals, default is 6 decimal places
: printf ("height is%.2f\n", height);
40:
41:
: char' D ';
: printf ("integral grade is%c\n", Scoregrade);
44:
45:
: printf ("score is%d, height is%f, rank is%c\n"' C ');
47:
: return 0;
: }
4. The scope of the variable starts with the line of code that defines the variable and ends at the end of the code block 5. The function of the code block reclaims the variables that are no longer in use, in order to improve performance 6. Exchange of variables 1). Leverage third-party variables (work, master)
1: int temp = A;
2: a = b;
3:
2). Do not use third-party variables (interviews, impressions)
1: a = b-a;
2: b = b-a;
3:
Dark Horse programmer--"Dark Horse video Notes" variable and scope of C language Foundation