CMSC 122 Lecture Notes - Lecture 21: Multiplication Table, Semicolon
CMSC 122 verified notes
21/46View all
Document Summary
Cmsc 122 lecture 21 oct 12. Examples: grid of asterisks, multiplication table, nested list. Trace tables: mechanism to keep track of values in a program, allows you to understand the program behavior, we could create a trace table for even numbers. Combination of statements: you can have any combinations of conditionals and iteration loop statements, for example, conditionals inside loops, conditionals inside conditionals, loops inside conditionals, loops inside loops. It computes the remainder when an integer x is divided by another integer y: an arithmetic operator commonly used in many applications, var r = x % y. If x = 9 and y = 4, answer will be 1. } while (condition): first execute the loop body then check condition, the difference to while loop is that do while loop is always executed at least once even if the condition is initially false.