Unformatted text preview: book)
num = 10; ans2 = num++; First assign num to ans2, then incr. num to 11.
12 What is a `Side Effect' ?
Side Effect == any value change(s) that are done by an operator Obvious Side Effects; `=' changes hats value
hats = 4; hats = hats*2; Not-So-Obvious Side Effects; what happens?
scanf(" %d", &hats); printf("and get %d coats", ++hats);
13 VERY BAD IDEA: Complex Embedded Side Effects
Legal in C (book: pg. 112), but DON'T! CONFUSING, ANNOYING to human readers (can hide nasty bugs in a program) OBSOLETE, UNNECESSARY (no longer makes C programs faster) Examples:
gloves = 2*(hats = coats++); printf("washed %d, got %d",socks,--socks); scanf("look for %d",&(hats++)); Bug!
14 Operators Expressions Expressions: the smallest `grains' of computing, the single units of evaluation, made of one operator and its input terms (or `operands') Examples: n+5 a...
View Full Document