sequence................................................. ................................................................. ................................................................. .5
Foreword........................................ ................................................................. ........................................7
Acknowledgments........................................................ ................................................................. ...........................................9
Chapter 1 Overview of C/C Language........................................ ................................................................. .............10
1.1 Basic framework of the program...................................... ................................................................. ............10
1.2 Variables........................................ ................................................................. .............................11
1.2.1 Definition of variables........................................ ................................................................. .......11
1.2.2 Assignment of variables................................................ ................................................................. .......11
1.2.3 Reference to variables........................................ ................................................................. .............12
1.3 Data types of C/C language........................................ ................................................................. .......12
1.4 Constants................................................ ................................................................. .............................14
1.5 Operators and expressions........................................ ................................................................. .............15
1.5.1 Arithmetic operators................................................ ................................................................. .......15
1.5.2 Assignment operator................................................ ................................................................. .......17
1.5.3 Relational operators................................................ ................................................................. .......17
1.5.4 Logical operators................................................ ................................................................. ............17
1.5.5 Bit operators................................................ ................................................................. .............18
1.6 Notes........................................ ................................................................. ...............................twenty two
1.7 Branch statement................................................ ................................................................. .........................twenty three
1.7.1 if statement................................................ ................................................................. .................twenty three
1.7.2 switch statement................................................ ................................................................. ...........twenty four
1.8 Loop statement................................................ ................................................................. .............26
1.8.1 for statement................................................ ................................................................. .............27
1.8.2 while statement................................................ ................................................................. ............28
1.8.3 do-while statement...................................... ................................................................. ..........28
1.8.4 break statement................................................ ................................................................. ............29
1.8.5 continue statement................................................ ................................................................. .........30
1.9 Functions...................................................... ................................................................. .............................30
1.9.1 Definition of function........................................ ................................................................. .......31
1.9.2 Function call........................................ ................................................................. .......32
1.9.3 Parameter passing and return value................................ ................................................................. ...32
1.9.4 Library functions and header files........................................ ................................................................. .......33
1.10 Standard input and output...................................... ................................................................. .............33
1.10.1 printf function (standard output function)........................................ .............................34
1.10.2 scanf function (standard input function) ........................................ .............................35
1.11 Global variables and local variables........................................ ................................................................. ......35
1.12 Array................................................ ................................................................. .............................37
1.12.1 One-dimensional array................................................ ................................................................. ............37
1.12.2 Two-dimensional array................................................ ................................................................. ............39
1.12.3 Initialization of array................................................ ................................................................. ........40
1.12.4 Array out of bounds........................................ ................................................................. .............41
1.13 String................................................ ................................................................. ........................41