This preview shows page 1. Sign up to view the full content.
Unformatted text preview: - 0123 is handled as 83(10) [ie. 1*8*8+ 2*8 + 3] - display 83 !! Can also be represented as Octal values: 0.. [ Be careful: 0123 123 ] Common operators for numbers: +, -, *, /, % Precedence of *, /, and % are higher than + and -. Example: 3-2*4 gives -5 (* is calculated before -). Parentheses ( and ) can be used for more complicated calculations. Example: final_mark = (assignment_mark + (testA + testB)/2)/2 * 0.3 + exam_mark * 0.7; 2 special operators: ++ and --: increment and decrement a variable by 1. Example: count++; is the same as count = count + 1; and counter += 1; count--; is the same as count = count - 1; and counter -= 1;
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong http://www.cs.cityu.edu.hk/~helena 4. Program Structure III - 11 Data Types
The results could only be true / false (Boolean values) Meani...
View Full Document
- Winter '08
- Computer Programming