Home /
Expert Answers /
Computer Science /
3-trace-the-following-algorithm-when-n-5-then-convert-into-flowchart-1-step-1-start-2-step-2-pa723
(Solved): 3. Trace the following algorithm when n=5, then convert into flowchart 1. Step 1: Start. 2. Step 2: ...
3. Trace the following algorithm when n=5, then convert into flowchart 1. Step 1: Start. 2. Step 2: Read a number n. 3. Step 2: Initialize variables: i=1, fact =1. 4. Step 3 : if i<=n go to step 4 otherwise go to step 7 . 5. Step 4: Calculate. fact = fact ?i. 6. Step 5: Increment the iby 1(i=i+1) and go to step 3 . 7. Step 6: Print fact. 8. Step 7: Stop.
Here's the trace of the given algorithm for n=5:Step 1: Start
Step 2: Read a number n. (n=5)
Step 3: Initialize variables: i = 1, fact = 1.
Step 3: Check if i <= n (1 <= 5), go to step 4.
Step 4: Calculate fact = fact * i (fact = 1 * 1 = 1).
Step 4: ...