CS 24000 Lecture Notes - Lecture 6: Switch Statement

12 views3 pages

Document Summary

Then continues to check against else if or else statements are used to then be executed: example: int i; // i get some value if(i != 0){ While statement while(expression): expression in while statement is converted to an int, while(expression) != 0 then the program continuous to loop until expression does equal 0, example: int i, j; while(i > j){ // code body that will continue to executed. For statement is typically used in situation where you know in advance the number of iterations: syntax: for(expression1; expression2; expression3), example: //assuming the variable i has been declared above. for(i = 0; i < 10; i++){ // code to be executed goes here. // loop until ! (i < 10) for a total. // of 10 iterations for statement: however you could use the for statement where a while statement is also used, example: expr1; while(expr2){ // body of statement to be executed expr3;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents