Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions dana/programs/palindrome.dana
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def checkPalindrome is byte: word as byte[]
var length is int := 0
loop:
if word[length] = '\0': break
length := length + 1

var i is int := 0
loop:
if i >= length / 2: break
if word[i] <> word[length - i - 1]:
return false
i := i + 1
return true

def main
var word is byte[100]

writestring: "Gimme a word!\n"
readstring: 100, word

if checkPalindrome(word):
writestring: "It is a palindrome!\n"
else:
writestring: "It is not a palindrome\n"