- Constants :
- Constants represent some fixed data, 0.0 is decimals, 0 is 0, floating-point type plus f;1.2f is single-precision floating point, 1.2 is double precision;
- The string is double-quoted, and the character is enclosed by single quotation marks;
- variables :
- Represents a variable data;
- How to define variables: variable type + variable name; As long as you define these, you will have storage space in memory;
- int score; The variable name is also one of the identifiers;
- As long as you define this variable, there will be a unique storage space for it;
- Different types have different sizes; The purpose of the write type is to constrain the size of the variable;
- Integer data 4 bytes; char type 1 bytes;
- Assignment Value :
- score = 1000; assignment operation; assignment operator; right to left; Char denotes character;
- each assignment will overwrite the previous value; The first assignment represents initialization; int a = 20;
- Variables can be defined consecutively; int d,e,f;
- b = A = 40; first give 40 a, then the value of a is assigned to B;
- printf ("Score is%d\n", score); %d is a format character; a placeholder;%d is used to occupy a position; the future is for score;%d can only be used to output integers;
- %f accuracy of the output,%f used to output decimals, default is 6 bits,%c means char type,%d and%i are the same, can represent integer type ;
- printf ("/score is%d\n", "", "", Score,height,socregrade);
- Summarize:
- Variable type and variable name, assignment of variable, output of variable; printf ("%d\n", a)
- The scope of the variable in the function:
- Variable is used with a scope
- The storage space of main is not fixed;
- A function is a large block of code, which can have small blocks of code;
- The code block is the place to constrain the code, and the code nearest to the scope is the principle;
- The code inside the code block only works within the code block, but if it is not implemented within the code block, it will jump to the nearest block of code;
- Blocks of code can improve performance;
- The compiler for the Mac computer is 64 bits, the corresponding data type byte number is: char 1 bytes; int 4 bytes; float 4 bytes; double 8 bytes;
- The variable starts with the line defined, functions to the end of the code block, and the code block can reclaim memory and improve performance in time;
Constant variable Assignment c