U3: Nested If Statements
暂无描述。系统推荐的高质量记忆内容,适合每天坚持背诵学习。
卡片预览 (16 张)
Program Control
• How program executes code, makes decisions and organizes functions • How and which lines of code get executed
Sequential Program Control
Lines executed from first to last; top to bottom
Selection and Program Control
Computer makes choices on what to execute based on data.
Switch Statement Code
switch (variable) { case “any”: case “ANY”: codea; break; default: codeb; break; }
Case Fall-Through
W/out break function, program executes each next case until reaching “break”
Switch Statements
• Similar to if-then-else statement • Useful when decision based on single character, word or value
Quotations with Cases
Use “” for characters; no quotations for numbers
Indenting and Braces
After every open brace, next line of code must be indented further
Nested if-then-else Statement
If-then-else statement programmed inside another if-then-else statement
White Space
Empty space/lines in the program
Coding Style
How code looks; Each person has a different coding style
Aspects of Coding Style [A]
• How/when comments used • # of spaces for indentation • Use of white space
Aspects of Coding Style [B]
• Naming of variables and functions • Code organization • Patterns used and avoided
Style Guides
• Set of rules outlining how person’s programming works • Workplaces and languages can have rules/conventions
Aspects of Style Guides [A]
• Communication is key so everybody can agree • Makes old code easier to understand
Aspects of Style Guides [B]
• Makes errors obvious • Explaining details important for style guide