Lecture 5: Variables and Operators
Monday, February 13, 2012[Up] [Previous Lecture] [Next Lecture]
Reading Assigned: 2.5-2.8
Homework Due: None
Homework Assigned: Homework 02
Classwork Assigned: Classwork 03
Topics Covered:
- What are variables?
- Why are they called variables?
- Naming variables
- Valid characters (letters, digits, underscores)
- Only first 31 characters are used
- Reserved words
- Standard identifiers (eg. printf, scanf)
- Demonstration program bad_variables.c
- Case matters
- Variable types (and sizes)
- int (4 bytes)
- double (8 bytes) format -- Note you are not required to know the IEEE double format encoding
- char (1 byte)
- Operators
- Arithmetic (+, -, *, /, %)
- Order of operations (*%/ then +- then =)
- Order of evaluation (left to right, except = is right to left)
- Parenthesis can change order of operations
- Example code
- Types of problems encountered in programs
- Syntax errors
- Fatal errors
- Control errors