01:198:170 Lecture Notes - Lecture 16: Global Variable, Local Variable, Texas State Highway Loop 1
taupebee294 and 9 others unlocked
9
01:198:170 Full Course Notes
Verified Note
9 documents
Document Summary
Global variable: global variables are declared w/i the main program (ie: var x,y,z and var ans) For loop: key word for , can declare a variable to act as a counter, has test statement. & update statement: create variable, test variable, if true perform loop and if not true skip the statements, continue loop until tests false. 3 types of loops: for, while, do-while: for: can utilize when you know the number of times you need 2 initiate loop. Good for when you"re using integers to test loop. For this class, only need to know for-loop. For (initialization; continuation; next iteration) { statement list. The for-loop is self-contained (set up counter, have your test & have your way to update it) Number of times the loop runs depends on your initial variable. Minimum times a loop can run = zero: starting point & next iteration: Can start your count anywhere; based on when you want your user to stop.