Another Simple Program 2

Another Simple Program 2 - More on Operators and...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
More on Operators and Assignments PLUS: Reading Input from the Keyboard!! If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer, it will get you. -- Peter Farrar One person's constant is another person's variable. -- Alan Perlis But First. .. More on Operators Operator precedence - highest to lowest
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Parentheses * / % <--- performed in order from left to right + - <--- performed in order from left to right Note : Recall that + is an operator that adds 2 numbers, but it also is the string concatenation operator when one or both operands are Strings. Examples : int result = 2 * ((16 - 4) / 2); // result is set to 12 String s = 4 + "6" + 2; // s is set to "462" result = 13 % 2 - 1; // result is set to 0 result = 13 % 2 * 4; // result is set to 4 Increment and Decrement Operators The increment operator ++ adds 1 to a number o result ++; // The value stored in result is increased by 1 The decrement operator -- subtracts 1 from a number o result --; // value stored in result is decreased by
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/24/2010 for the course CS 305j taught by Professor Mikescott during the Spring '10 term at University of Texas at Austin.

Page1 / 7

Another Simple Program 2 - More on Operators and...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online