Article Directory
1. Variable
The variable is the amount of change.
In C language, constants are used to represent unchanging values, and variables are used to represent changing values.
eg: output 26 letters
#include <stdio.h>
int main()
{
char c = 'A';//定义一个为char类型的变量c,并对其进行初始化
for (; c <='Z'; c++)
{
printf("%c", c);
}
printf("\n");
return 0;
}
2. Definition of variables
int temp;
int age = 21;
float weight = 51.2f;
char ch = 'V';
2.1 Variable definition format
int a = 10;
type variable name assignment operator content
2.2 Defining the nature of variables
Open up a space corresponding to the size of the variable in the computer memory.
2.3 Initialization and assignment of variables
Initialization: Assign values to variables when they are defined.
eg: int age = 21;
Assignment: Assign a new value to an existing variable.
eg: age=22;
(1) float weight = 45.5f; It is recommended to bring f when representing a floating-point number of float type, and do not use double type.
(2) int temp; If the variable is not initialized when it is defined, the system will assign a random value to it.