90 likes | 172 Views
Variables as Containers. Variables have: Name Type Data. int length; l ength = 7;. Conditional Statements. if(condition) statement; if(length < 7) { statements; statements; }. Operators. < Less than <= Less than or equal > Greater than >= Greater than or equal == Equal to
E N D
Variables as Containers Variables have: Name Type Data
int length; length = 7;
Conditional Statements if(condition) statement; if(length < 7) { statements; statements; }
Operators • < Less than • <= Less than or equal • > Greater than • >= Greater than or equal • == Equal to • != Not equal
Loops • Initialization • Condition • Update • Body
for loop - precondition for(initialization; condition; increment) statement; for(int control = 0; control < max; control++) { statement; statement; }
while loop - precondition • initialization; • while(condition) • { • statements… • Increment condition; • }
do loop - post condition • initialization; • do • { • statements… • Increment condition; • }while(condition);
functions prototype: Looks just like your function header int count(int accumulator); int count(int accumulator) { Statements… }