The Procedure
Real Lab Procedure
- Creating a variable "num" to hold the number entered by the user.
- Variable "fact" is used to hold the factorial of the given number, which is initialized to value 1.
- Loop variable "i" is initialized to the value 1.
- "while" loop is used to calculate the factorial of the given number.
- "while" loop will execute until "i" is less than or equal to the given number.
- Inside "while" loop, two important operations are carried out:
- fact = fact * i
- i = i + 1
- When exiting the "while" loop, print the factorial of the given number.
Simulator Procedure
- Enter the input values.
- Click on the Submit button.
- Select the variables from the dropdown list.
- Click on the Finish button or Start button to view the state diagram.
- If you have clicked on the Start button then use Next and Previous button to view the State diagram.
- Click on the Reset button when the State diagram is completed.