Welcome! Log In Create A New Profile

Advanced

second assignment

Posted by Hitch 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
second assignment
October 06, 2011 09:50AM
1. Display the following prompt: "Enter the number for the factorial calculation (0 to 8):"
2 Accept the number from the keyboard as an ASCII string.
3. Convert the string to a numeric value.
4. Call a subroutine that calculates the factorial of the number.
5. Convert the result to an ASCII string and display it on the screen.
6. Terminate the program when a key such as "Q" is pressed.
N.B. Keep the following in mind:
1. The value must be passed to both subroutines as a parameter on the stack. The result should also be
passed back to the calling program on the stack.
50
2. Use either of the following two algorithms as guidelines for your subroutines:
Iterative function FactIter (N):
Result = 1;
For I = 2 to N do
Result = Result * I;
FactIter = Result;
Recursive function FactRec (N):
If N = 1 then
FactRec = 1
else
FactRec = N * FactRec (N-1);
Sorry, only registered users may post in this forum.

Click here to login