-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_operators.kt
43 lines (38 loc) · 1.16 KB
/
03_operators.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
fun main() {
var x = 10
var y = 5
// Arithmetic Operators
println("Addition : " + (x + y)) // Addition
println("Subtraction : "+(x - y)) // Subtraction
println("Multiplication : "+(x * y)) // Multiplication
println("Division : "+(x / y)) // Division
println("Modulus : "+(x % y)) // Modulus
x++ // Increment
y-- // Decrement
println(x)
println(y)
// Assignment Operators
println("Assignment Operators")
x += 3
println(x) // x = x + 3
x -= 2
println(x) // x = x - 2
x *= 2
println(x) // x = x * 2
x /= 2
println(x) // x = x / 2
x %= 3
println(x) // x = x % 3
// Comparison Operators
println("COmparision Operators")
println(x == y) // Equal to
println(x != y) // Not equal
println(x > y) // Greater than
println(x < y) // Less than
println(x >= y) // Greater than or equal to
println(x <= y) // Less than or equal to
// Logical Operators
println(x < 5 && x < 10) // Logical AND
println(x < 5 || x < 4) // Logical OR
println(!(x < 5)) // Logical NOT
}