But be very careful see book num 10 ans2 num first

Info icon This 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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern