Loops and switches Flashcards
while loop
while (this case is true) {
we will execute this}
for loop
a loop with a built in iteration system
for loop syntax
for(int I =0; i<10; i++)
iterational statement
the statement that iterates the loop for you
if there is no iteration statement then you have an infinite loop
switch statement format
switch(variable value) case "a" stuff break case "b:" ... break default
break in a switch statemtn
stops the code below from being executed
without it the next case executes too.
default in switch statement
the default will execute if none of the cases execute
for(x=1;x<=10;x=x+1) cout «_space;x
1 2 3 4 5 6 7 8 9 10
do while loops
loops that execute before giving the case statement
code for do-while loop
do { statement; } while (expression);
Format for for loop
for (initialization; test; update)
statement;
EX for (count = 0; count < 5; count ++) cout << "Hello!" << endl;
I++
post incriment uses the current value of i and then incrtiments for next time
++I
pre incriment uses the incrimented value of I and then incriments for next time
nested loop
one loop inside of another loop
kill the program
ctrl c