But be very careful see book num 10 ans2 num first

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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

This note was uploaded on 10/05/2011 for the course COMPUTER S 110-1 taught by Professor Tumblin during the Spring '11 term at Northwestern.

Ask a homework question - tutors are online