Complete real-world programs built using Mewar Programming Language.
set a to ask "Enter First Number:"
set b to ask "Enter Second Number:"
say (a + b)
say (a - b)
say (a * b)
say (a / b)
set marks to ask "Enter Marks"
if marks >= 90 then
say "Grade A"
elif marks >= 75 then
say "Grade B"
else
say "Grade C"
end
set balance to 1000
set withdraw to 200
balance -= withdraw
say balance
set items to ["Sword","Shield"]
append "Bow" to items
show items
set answer to ask "Capital of India?"
if answer is "Delhi" then
say "Correct"
else
say "Wrong"
end
matrix A = [[1,2],[3,4]]
matrix B = [[5,6],[7,8]]
say "Matrix A:"
show A
newline
say "Matrix B:"
show B
newline
# ----- ADDITION -----
say "A + B:"
set Add to A + B
show Add
set food to 500
set travel to 300
set total to food + travel
say total
say "King's land"
newline
say 'He said "Welcome"'
newline
set quote to 'Mewar's power'
say quote
newline
set msg to "She said "Victory""
say msg
newline
goal quote is "Mewar's power"
explain program
# ---------- LIST TEST ----------
set nums to [1,2,3,4,5,6]
set banned to [2,4,6]
say "List check:"
for n in nums then
if n not in banned then
say n + " is allowed"
else
say n + " is blocked"
end
end
newline
# ---------- STEP + NOT IN ----------
say "Step loop with not in:"
set skip to [3,7]
for i in step(1,10,1) then
if i not in skip then
say i
end
end
newline
# ---------- STRING IN / NOT IN ----------
set name to "MewarLanguage"
say "String check:"
if "war" in name then
say "'war' found in name"
end
if "xyz" not in name then
say "'xyz' not found in name"
end
set score to 10
set score to 20
set score to 40
say @score
say @*score
# ---------- NUMBER CAST ----------
set num1 to number("123")
say "number("123") = " + num1
say "num1 + 10 = "
say num1 + 10
newline
# ---------- STRING CAST ----------
set text1 to string(100)
say "string(100) = " + text1
say "Concatenation test:"
say text1 + " King"
newline
# ---------- PURE MATH ----------
say "Pure math test:"
say 20 + 30
say 50 - 10
say 6 * 5
newline
# ---------- MIXED EXPRESSION ----------
set x to number("50")
set y to 25
say "Mixed math:"
say x + y
newline
# ---------- LIST TEST ----------
set nums to [1,2,3]
say "List test:"
say nums
newline
# ---------- STEP + CAST ----------
say "Step test:"
for i in step(1,5,1) then
say i + 1
end
newline
# ---------- INVALID CAST TEST ----------
say "Invalid cast test:"
test
set bad to number("abc")
fail err then
say "Error handled: " + err
end
newline
say "=== BOOLEAN TEST ==="
set a to boolean(1)
set b to boolean(0)
set c to boolean("true")
set d to boolean("false")
set e to boolean("hello")
say a
say b
say c
say d
say e
set sales to 500
set sales to 1000
show sales
explain sales
goal sales >= 1000
say @sales