Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Constants and Variables in C Language
Constants and Variables in C Language
C Programming Lecture Notes-Constant Variables

Teaching objectives:

1. Master constants and variables in C programming.

2. Complete the experimental report and send it back to the teacher's computer.

Teaching emphases and difficulties:

Difference and accurate use of floating-point number, integer and other data types

Teaching form:

experiment

Teaching conditions:

computer

Teaching content:

1. identifier

1. 1 Character set:

(1) English letters: A-Z, a-z.

(2) Numbers: 0-9

(3) Special symbols: spaces, tabs (tabs) and line breaks (blank lines). Punctuation, special characters:

1.2 identifier (name):

1) Identifier can only consist of letters, numbers and underscores, and the first character must be a letter or underscore. Case sensitive.

2) ANSI C does not limit the identifier length, but each compilation system has its own rules and restrictions (TC 32 characters, MSC 8 characters).

3) Identifiers with different case.

4) When using identifiers, try to adopt the principle of "knowing the meaning by name and keeping it simple forever".

5) The identifier cannot have the same name as the predefined keyword or standard identifier.

1.3 identifier classification

(1) keywords (reserved words): 32 strings with specific meanings specified by C language, which cannot be used as user identifiers.

(2) Predefined identifiers: library function names and compilation preprocessing commands provided by C language.

(3) User identification symbol: an identifier defined by the user.

1.4 operator: the operator connects constants, variables and functions to form an expression, representing various operations.

According to the number of operands involved in the operation, it is divided into monocular, binocular and tricular operators.

1.5 separator: comma, space.

1.6 note: "/*" and "*/"form a set of notes.

2. Constant and variable

Constant: A quantity whose value cannot be changed during the running of a program is called a constant.

Variable: The amount whose value can be changed during the running of a program is called a variable.

2. 1 constant

Integer constant, real constant, character constant.

The symbolic constant # defines PI 3. 14 16.

2.2 variables

In the process of running a program, the amount whose value can be changed is called a variable.

The relationship between variable name (represented by identifier), storage unit occupied by variable in memory and variable value.

● Variables in C language: "Define first, then use".

3. Integer data

Definition of integer variables

Format: data type name variable name table;

For example:

void main()

{

int a,b,c,d;

a = 12; b =-24; u = 10;

c = a+u; d = b+ u;

printf("%d,%d\n ",c,d);

}

Description:

1) variable definition, which can explain multiple variables of the same type. Variables are separated by ",".

2) ";" Must be used after the last variable name. The ending.

3) The variable description must be before the variable is used.

4) You can initialize variables while defining them.