Introduction to Character Types and Variables
1. What is C language?
Simply put, C is the language for people and machines to communicate
2. Data Type
type of data | specific explanation |
---|---|
char | // character data type |
short | //short integer |
int | //shape |
long | // long integer |
long long | //Longer reshape |
float | //Single precision floating point number |
double | //double precision floating point number |
char | // character data type |
short | //short integer |
int | //shape |
long | // long integer |
long long | //Longer reshape |
float | //Single precision floating point number |
double | //double precision floating point number |
2.1 What is the size of each of these types?
2.2 What are the sizes of these types?
a: Bit is bit, which is the smallest storage unit of a computer. The storage units of a computer are as follows:
storage unit | meaning | Conversion method |
---|---|---|
byte | Represented by B or Byte, it is the basic unit used to represent storage capacity, 1 byte contains 8 bits | 1 B = 8 bit |
kilobytes | Expressed in KB, 1 kilobyte contains 1024 bytes | 1 KB = 1024 B |
megabytes | Expressed in MB, 1 megabyte contains 1024 kilobytes. | 1 MB = 1024 KB |
gigabytes | Expressed in GB, 1 gigabyte contains 1024 megabytes. | 1 GB = 1024 MB |
terabyte | Expressed in terabytes, 1 terabyte contains 1024 gigabytes. | 1 TB = 1024 GB |
petabytes | Expressed in PB, 1 petabyte contains 1024 terabytes. | 1 PB = 1024 TB |
Exabyte | Expressed in EB, 1 exabyte contains 1024 petabytes. | 1 EB = 1024 PB |
Zettabytes | Expressed in ZB, 1 zettabyte contains 1024 exabytes | 1 ZB = 1024 EB |
Yao bytes | Expressed in YB, 1 Yao byte contains 1024 zettabytes | 1 YB = 1024 ZB |
2.3 Variables and Constants
The constant is called a variable such as: gender, and the variable that will change is a constant such as: weight
Variable definition: char w='a';
2.4 Global and local variables
Global variables: Variables defined outside {} braces, that is, variables defined outside a function are called global variables
Local variables: Variables defined inside {} braces
Scope (life cycle)
Global variables: The scope starts from the defined position to The end of this source file
Local variables: the scope of action is the end of the entire program
When there is a conflict between the global variable name and the local variable name, the local variable takes precedence. We must avoid the conflict between local variables and global variables when defining variables, so as not to bring unnecessary trouble