Escape Sequences¶
Sequence | Description |
---|---|
\t | tab |
\n | new line |
\" | quotation mark |
\\ | backslash |
Data Types¶
Type | Description | Examples |
---|---|---|
int | integers, numbers without fractional components | 42 , -3 , 92851 |
double | decimal numbers | 3.14 , 2.0 |
String | text | "Hello" , "CSE 121" |
boolean | logical values | true , false |
Expressions¶
- Precedence:
()
before*
/
%
before+
-
- with
int
,/
is integer division and%
is integer remainder - Strings can be concatenated with other values
Arithmetic Operators¶
(Compute a value using arithmetic operations)
Operator | Meaning |
---|---|
+ | addition |
- | subtraction, negation |
* | multiplication |
/ | division |
% | remainder (“modulus”) |
Relational Operators¶
Operator | Description |
---|---|
< | less than |
<= | less than or equal |
> | greater than |
>= | greater than or equal |
== | equal |
!= | not equal |
Logical Operators¶
(Evaluate expressions as true or false)
Operator | Description |
---|---|
&& | and |
|| | or |
! | not |
Truth Table for &&
¶
Expression | Result |
---|---|
true && true | true |
true && false | false |
false && true | false |
false && false | false |
Truth Table for ||
¶
Expression | Result |
---|---|
true || true | true |
true || false | true |
false || true | true |
false || false | false |