The instructor evaluates the proper solution for ensuring the math calculation is based on the order of evaluation. Other alternatives are presented, though incorrect, with an explanation of why they fail.
(upbeat music) … - I hope you appreciated the descriptive variable names … in the Challenge Exercise File. … Programmers who write good code, use names such as these. … No confusion. … Starting at line seven, I assign 12 to the variable rooms, … 16 to variable paintings, … and four to variable sculptures. … The proper equation is listed at line 11. … The calculation inside the parentheses happens first. … The value of paintings is added to the value of sculptures. … Once this value is obtained, … the equation works left to right. … With the number of rooms multiplied … by the result of the operation in parentheses. … If you omit the parentheses, … rooms is multiplied by paintings first. … And then that whole result is added to sculptures. … This outputs an incorrect result, 196. … Only when you use parentheses … to override the order of precedence, … will you arrive at the proper result … and keep your cushy programming job at the museum. … …
- Writing your first C program
- Working the C development cycle
- Adding comments to code for clarity
- C language data types
- Declaring variables
- Making new data types
- Typecasting variables
- Using math, assignment, and logical operators
- Creating for and while loops
- Nesting loops
- Creating functions
- Returning values from functions
- Passing arguments to functions
- Creating recursive functions
Skill Level Intermediate
C: Data Structures, Pointers, and File Systemswith Dan Gookin2h 57m Intermediate
1. The Fundamentals of C
2. Variables and Values
3. Operators and Math
4. Decisions and Loops
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.