Things you need to know to complete homework3 ---------------------------------------------- Read chapter 3 in the K&R C book! This chapter covers C control structures like 'if' and 'for'. Also, read the portions of chapter 4 explaining C arrays. This material was covered in class, but the book provides a very complete specification as well as program examples. The syntax of the 'if' control structure, for instance, is as follows: if() else Where is any expression that results in a zero or non-zero value. and are simply statements, and recall that statements can be contained in blocks by wrapping them in curly braces "{}". This needs to be done if you wish to execute multiple statements inside a control structure, for example: int a=10; int b=20; int c; if (a < b) { printf("a is less than b!\n"); c = a + b; printf("also, a + b is: %d\n", c); } else { printf("a is greater than or equal to b\n"); } Since the above example had three statements that were supposed to execute if the if condition were satisfied, we use curly braces to define the statement block. We can use a 'for'loop to iterate through C arrays: int i; float myarray[4]; for (i=0; i<4; i++) { myarray[i] = 1; printf("just set myarray at index %d to %d\n", i, myarray[i]); } The same concept of statement blocks extends to loop structures, where if we want multiple statements to execute inside the loop, we must enclose them in curly braces. email nurmi@cs.ucsb.edu or tan@cs.ucsb.edu with questions! Start early! Come to office hours or schedule a time when we can meet to get help (via email)!