90 likes | 182 Views
Learn about variables as containers, conditional statements, operators, loops, and functions in programming. Understand data types, control flow, and loops in this comprehensive guide.
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… }