Skip to content

Commit

Permalink
Add some inputs and results for grace programs
Browse files Browse the repository at this point in the history
  • Loading branch information
kostis committed May 19, 2024
1 parent ca3c313 commit 111dabb
Show file tree
Hide file tree
Showing 11 changed files with 463 additions and 18 deletions.
2 changes: 1 addition & 1 deletion grace/programs/divisibleby3.grc
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ fun main() : nothing
writeString(" is ");
if divisibleBy3(n) # 1 then
writeString("not ");
writeString("divided by 3.\n");
writeString("divisible by 3\n");
} $ main
1 change: 1 addition & 0 deletions grace/programs/divisibleby3.result
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
54 is divisible by 3
10 changes: 9 additions & 1 deletion grace/programs/evenodd.grc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ $$

fun main(): nothing

fun abs(n: int): int
{ $ abs
if n < 0 then
return -n;
else
return n;
}

fun even(n: int): int;

fun odd(n: int): int
Expand All @@ -33,7 +41,7 @@ fun main(): nothing
{ $ main
writeString("Please, give an integer: ");

if odd(readInteger()) = 1 then
if odd(abs(readInteger())) = 1 then
writeString("odd\n");
else
writeString("even\n");
Expand Down
1 change: 1 addition & 0 deletions grace/programs/evenodd.input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4711
1 change: 1 addition & 0 deletions grace/programs/evenodd.result
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please, give an integer: odd
2 changes: 2 additions & 0 deletions grace/programs/functionestscope.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Test 1 Success
Test 2 Success
2 changes: 1 addition & 1 deletion grace/programs/hanoi.input
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7
9
Loading

0 comments on commit 111dabb

Please sign in to comment.