C language tutorial -3 data types, variables and constants
Basic types:
Arithmetic type, including two types: integer type and floating point type. The integer is an int, an unsigned int, an integer that represents a positive or negative number, a positive float, and a double that represents a decimal
The character type char represents a byte, that is, a symbol, ‘#’, enclosed in single quotes
Boolean type bool, which has two results, true and false, representing true and false, and plays a role in logical judgment
Variables: Variables should be declared before they are used. Declare it as follows. int i, j, k; char c, ch; float f, salary; double d; bool e;
The idea behind a variable is to give a name to an unknown quantity. But it is best to use specific English expression, develop good programming habits.
Constants: quantities that never change
There are two ways to define constants. Use the #define preprocessor. Use the const keyword
#define X 10
const int Y= 10;
Now neither X nor Y can change.