30 likes | 94 Views
Computer Science. Errors & Debugging Structures & Loops. Avoiding Errors with if statements. Floating points are not good test values especially if you are using them for comparison Don’t forget to enclose Blocks of code in Brace brackets { }
E N D
Computer Science Errors & Debugging Structures & Loops
Avoiding Errors with if statements • Floating points are not good test values especially if you are using them for comparison • Don’t forget to enclose Blocks of code in • Brace brackets { } • Use the comparison operator == in if statements not the assignment operator = • Initialize values in if statements to take into account all eventualities • Use boolean operators correctly to combine conditions
Avoiding errors with loops • For a counted loop use for • For a pre-test conditional loop use while • For a post-test conditional loop use do • For a counting and condition loop use for • Initialize all variables • Watch for infinite loops • Use boolean operators correctly to combine conditions