-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cin
More file actions
82 lines (67 loc) · 1.13 KB
/
Copy pathexample.cin
File metadata and controls
82 lines (67 loc) · 1.13 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# this is an comment. cinnamon supports single line comments only.
puts "Basic Output"
puts "Hello, World!"
puts 42
puts 3.14
puts true
puts false
puts "Variables and Assignment"
x = 10
y = 20
z = x + y
puts x
puts y
puts z
puts "Arithmetic Operations"
puts 5 + 3
puts 10 - 4
puts 6 * 7
puts 20 / 4
puts 2.5 * 2
puts "Comparisons"
puts 5 > 3
puts 10 < 8
puts 7 == 7
puts 5 == 3
puts "If Statements"
if 5 > 3 then
puts "5 is greater than 3"
end
puts "If/Else"
a = 15
if a > 20 then
puts "a is greater than 20"
else
puts "a is 20 or less"
end
puts "While Loops"
count = 0
while count < 3 do
puts count
count = count + 1
end
puts "Function Definition"
def greet(name)
puts "Hello, "
puts name
end
greet("Alice")
greet("Bob")
puts "Function with Return"
def add(a, b)
return a + b
end
result = add(5, 3)
puts result
puts "Complex Expression"
puts (10 + 5) * 2
puts "File Operations"
write_file("test.txt", "Hello from Cinnamon!")
puts "Wrote to test.txt"
content = read_file("test.txt")
puts "Read from test.txt:"
puts content
puts "HTTP Fetch"
response = fetch("https://httpbin.org/get")
puts "Fetched response:"
puts response