2 8 Common Programming Errors Syntax Errors Figure

  • Slides: 6
Download presentation
2. 8 Common Programming Errors • Syntax Errors (Figure 2. 15) – missing semicolon

2. 8 Common Programming Errors • Syntax Errors (Figure 2. 15) – missing semicolon at the end of the variable declaration (line 271) – undeclared variable miles (line 275 & 278) – last comment is not closed because of blank in */ closecomment sequence (line 280) • Run-Time Errors (Figure 2. 16) – an attempt to perform an invalid operation, detected during program execution • Undetected Error and Logic Errors (talks later) 中正大學通訊 程系 潘仁義老師 Advanced Network Technology Lab 1

Figure 2. 15 Compiler Listing of a Program with Syntax Errors 中正大學通訊 程系 潘仁義老師

Figure 2. 15 Compiler Listing of a Program with Syntax Errors 中正大學通訊 程系 潘仁義老師 Advanced Network Technology Lab 2

Figure 2. 16 A Program with a Run-Time Error 中正大學通訊 程系 潘仁義老師 Advanced Network

Figure 2. 16 A Program with a Run-Time Error 中正大學通訊 程系 潘仁義老師 Advanced Network Technology Lab 3

Common Programming Errors • Undetected Errors – a very common source of incorrect results

Common Programming Errors • Undetected Errors – a very common source of incorrect results in C programs is the input of a mixture of character and numeric data. • Logic Errors – an error caused by following an incorrect algorithm. 中正大學通訊 程系 潘仁義老師 Advanced Network Technology Lab 4

Figure 2. 17 Revised Start of main Function for Coin Evaluation 中正大學通訊 程系 潘仁義老師

Figure 2. 17 Revised Start of main Function for Coin Evaluation 中正大學通訊 程系 潘仁義老師 Advanced Network Technology Lab 5

Figure 2. 18 A Program That Produces Incorrect Results Due to & Omission 中正大學通訊

Figure 2. 18 A Program That Produces Incorrect Results Due to & Omission 中正大學通訊 程系 潘仁義老師 Advanced Network Technology Lab 6