-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: pz2 <[email protected]> Co-authored-by: Ben Boyter <[email protected]>
- Loading branch information
1 parent
e995f3d
commit 68aaddf
Showing
6 changed files
with
111 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
Constants and macro definitions for the program | ||
https://github.com/boyter/scc/issues/484 | ||
*/ | ||
|
||
// Define a constant for the number to calculate factorial | ||
#define NUM_TO_FACTORIAL 5 | ||
|
||
// Define messages to display | ||
#define MSG_FACT_GT_100 "Factorial is greater than 100" | ||
#define MSG_FACT_LE_100 "Factorial is less than or equal to 100" | ||
|
||
// Define a macro for maximum factorial limit | ||
#define MAX_FACT_LIMIT 100 | ||
|
||
// Prototype for the Factorial function | ||
FUNCTION Factorial( n ) | ||
RETURN NIL | ||
|
||
// Prototype for the Main function | ||
FUNCTION Main() | ||
RETURN NIL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
This program demonstrates the calculation | ||
of the factorial of a number using a function. | ||
https://github.com/boyter/scc/issues/484 | ||
*/ | ||
|
||
FUNCTION Factorial( n ) | ||
LOCAL result := 1 | ||
LOCAL i | ||
|
||
// Loop from 1 to n | ||
FOR i := 1 TO n | ||
result := result * i | ||
NEXT | ||
|
||
RETURN result | ||
|
||
// Main program execution starts here | ||
FUNCTION Main() | ||
LOCAL num := 5 | ||
LOCAL fact | ||
|
||
// Calculate the factorial of the number | ||
fact := Factorial( num ) | ||
|
||
// Check if the factorial is greater than 100 | ||
IF fact > 100 | ||
? "Factorial is greater than 100" | ||
ELSE | ||
? "Factorial is less than or equal to 100" | ||
ENDIF | ||
|
||
RETURN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters