Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
30 views2 pages

Pseudocode Control Based Analysis

The document provides a comparison between original and corrected pseudocode for summing numbers. Key errors in the original pseudocode include incorrect incrementing of the loop counter, printing the sum inside the loop, inconsistent casing, and improper assignment syntax. The corrected pseudocode addresses these issues, ensuring clarity and proper structure.

Uploaded by

st-sdube
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Pseudocode Control Based Analysis

The document provides a comparison between original and corrected pseudocode for summing numbers. Key errors in the original pseudocode include incorrect incrementing of the loop counter, printing the sum inside the loop, inconsistent casing, and improper assignment syntax. The corrected pseudocode addresses these issues, ensuring clarity and proper structure.

Uploaded by

st-sdube
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Great!

Let's analyse the pseudocode you provided:

---

### ❌ **Your Original Pseudocode:**

```text

Sum = 0

FOR count = 1 to 20

INPUT 'Enter number ', Number

SUM = Sum + Number

count = count + 1

PRINT sum

Next

```

---

### ✅ **Corrected Pseudocode with Explanations:**

```text

Sum ← 0

FOR count ← 1 TO 20

INPUT "Enter number", Number

Sum ← Sum + Number

NEXT

PRINT Sum

```

---
### 🔍 **Errors and Fixes Explained:**

| ❌ Error | ✅ Correction | 💬 Why It's Wrong


|

| ----------------------------------------- | ------------------------------------ |
--------------------------------------------------------------------------------------------------------------------------- |

| `count = count + 1` inside the loop | ❌ **Remove this line** | In a `FOR` loop, the
counter is **automatically incremented**. Manually incrementing it causes the loop to skip
iterations. |

| `PRINT sum` inside the loop | ✅ **Move it outside** the loop | You likely want to print
the total **after** all inputs are added. |

| Inconsistent casing (`SUM`, `Sum`, `sum`) | ✅ Use consistent casing, e.g., `Sum` | Pseudocode is not
case-sensitive, but consistent casing helps readability and avoids confusion. |

| Assignment (`=`) instead of `←` | ✅ Use `←` for clarity | In IGCSE pseudocode,
assignments are shown as `←`, not `=`. |

| Input format: `'Enter number ', Number` | ✅ Use `INPUT "Enter number", Number` | The string
should be in quotes, and `INPUT` should follow the correct format. |

---

### ✅ Final Version:

```text

Sum ← 0

FOR count ← 1 TO 20

INPUT "Enter number", Number

Sum ← Sum + Number

NEXT

PRINT Sum

```

---

Let me know if you want this as a flowchart or diagram!

You might also like