Variables and constants
You must declare a variable before using the variable. The syntax for a variable definition is:
For example, we can define an integer variable like this:
int A; int type denotes integral type
To declare multiple variables, you can declare them individually, or you can add multiple variable names after the data type name, separated by commas:
Data type name variable name 1, variable name 2, variable name 3;
You can assign a value to a variable while creating it, that is, initializing the variable. The syntax is:
Data type name Variable name = value;
It is a good idea to initialize variables when creating variables. This is because some compilers initialize to 0 by default, and some compilers perform operations such as output or arithmetic if the variables are not initialized, and the results you get will be random.
The definition of a constant, add a const keyword before the variable definition:
Const data type name Variable name = value;
When declaring constants, remember to initialize them, because constants can be assigned only when they are initialized, and in other cases assignments are not allowed. Once a constant is initialized, its value cannot be changed.
Try the knife, code the C language variables and constants.
#include <stdio.h> int main (void) {//Create an integer variable A, initialize to 1//create an integer constant Max, initialize to 100//write down your code int here A = 1; const int MAX = 100; printf ("a=%d, max=%d", A, MAX); return 0; }
Learn more about the code Bud NET, Http://www.mayacoder.com/lesson/index
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/85/DE/wKioL1etKaexY4OVAAAO_l6kxUw029.png-wh_500x0-wm_3 -wmp_4-s_2257600308.png "title=" 2.png "width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:400px; height:230px; "alt=" Wkiol1etkaexy4ovaaao_l6kxuw029.png-wh_50 "/>
Basic data types for C language Basics-variables and constants