Syntax refers to the grammar, structure and order of the elements in a statement, Logic errors occur when there is an error in the logic, fixing the errors may result in further errors being displayed when recompiled, A warning is not an error, but may cause problems during the execution of your program.

Data Recovery PRO DATA DOCTOR

Home | Order Online | Downloads | Contact Us | Software Knowledgebase

it | es | pt | fr | de | jp | kr | cn | ru | nl | gr


Debugging and Testing

Syntax Errors

Syntax refers to the grammar, structure and order of the elements in a statement. A syntax error occurs when we break the rules, such as forgetting to end a statement with a semicolon. When you compile the program, the compiler will produce a list of any syntax errors that it may encounter.

A good compiler will output the list with a description of the error, and may provide a possible solution. Fixing the errors may result in further errors being displayed when recompiled. The reason for this is that the previous errors changed the structure of the program meaning further errors were suppressed during the original compilation.

Similarly, a single mistake may result in several errors. Try putting a semicolon at the end of the main function of a program that compiles and runs correctly. When you recompile it, you will get a huge list of errors, and yet it's only a misplaced semicolon.

As well as syntax errors, compilers may also issue warnings. A warning is not an error, but may cause problems during the execution of your program. For example assigning a double-precision floating point number to a single-precision floating point number may result in a loss of precision. It is not a syntax error, but could lead to problems. In this particular example, you could show intent by casting the variable to the appropriate data type.

Consider the following example where x is a single-precision floating point number, and y is a double-precision floating point number. y is explicitly cast to a float during the assignment, which would eliminate any compiler warnings.

x = (float)y;

Logic Errors

Logic errors occur when there is an error in the logic. For example, you could test that a number is less than 4 and greater than 8. That could not possibly ever be true, but if it is syntactically correct the program will compile successfully. Consider the following example:

if (x < 4 && x > 8)
puts("Will never happen!");

The syntax is correct, so the program will compile, but the puts statement will never be printed as the value of x could not possibly be less than four and greater than eight at the same time.

Most logic errors are discovered through the initial testing of the program. When it doesn't behave as you expected, you inspect the logical statements more closely and correct them. This is only true for obvious logical errors. The larger the program, the more paths there will be through it, the more difficult it becomes to verify that the program behaves as expected.

Sample Chapters from book DATA RECOVERY WITH AND WITHOUT PROGRAMMING by Author Tarun Tyagi
Data Recovery with & without Programming


Publishers of the Book
Number of Pages
ISBN
Price of the Book


BPB Publications, New Delhi, India
540
81-7656-922-4
$69.00 (Including Shipping Charges, Cost of Book and Other expenses, Free Source Code CD included with the Book)





Buy Data recovery Book

Previous page

page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20

 
 

page 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37

 
 

page 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54

 
 

page 55 | 56 | 57 | 58 | 59 | 60

Next page

© Copyright 2002-2005 DataDoctor.Biz

Home | Contact us | Downloads | Services | Terms and conditions | Site map

Website Data Recovery | recuperación de Datos | Récupération de données | Datenrettung | Recupero dati | データ復旧 | 데이터 복구 | 数据恢复 | Восстановление данных | De terugwinning van gegevens | Ανάκτηση δεδομένων
Sitemap Site map1 2 3 4 | Spanish1 2 3 | French1 2 3 | German1 2 3 | Italian1 2 3 | Portuguese1 2 3 | Japanese1 2 3 | Korean1 2 3 | Chinese1 2 3 | Russian1 2 3 | Dutch1 2 3 | Greek1 2 3
Data Recovery Book English | Spanish | French | German | Italian | Portuguese | Japanese | Korean | Chinese | Russian | Dutch | Greek