Files
TDT4205/ps6/vsl_programs/ps6-codegen2/if.vsl
T
2026-04-28 15:27:55 +02:00

74 lines
1.4 KiB
Plaintext

func main(a) {
if (a < 10)
println("a is less than 10")
if (a > -5)
println("a is more than -5")
else
println("a is less than or equal to -5")
if (a == 5)
println("a is equal to 5")
if (a != 0 and a != 4)
println("a is neither 0 nor 4")
if (a == 0 or a == 4)
println("a is 0 or 4")
if (a != 0) {
println("a is not equal to 0")
if (a == 6)
println("a is however 6")
else if (a == 7)
println("a is however 7")
else if (a == 10)
println("a is however 10")
else
println("a is neither 0, 6, 7 or 10, but ", a)
if (a == 10) {
println("10 is my favorite")
} else {
println("I'm not happy about it either")
}
print("FIN? ")
}
println("FIN.")
}
//TESTCASE: 4
//a is less than 10
//a is more than -5
//a is 0 or 4
//a is not equal to 0
//a is neither 0, 6, 7 or 10, but 4
//I'm not happy about it either
//FIN? FIN.
//TESTCASE: 0
//a is less than 10
//a is more than -5
//a is 0 or 4
//FIN.
//TESTCASE: 10
//a is more than -5
//a is neither 0 nor 4
//a is not equal to 0
//a is however 10
//10 is my favorite
//FIN? FIN.
//TESTCASE: -20
//a is less than 10
//a is less than or equal to -5
//a is neither 0 nor 4
//a is not equal to 0
//a is neither 0, 6, 7 or 10, but -20
//I'm not happy about it either
//FIN? FIN.