0% found this document useful (0 votes)
35 views22 pages

Correcting Errors in Pseudocode

This document contains pseudocode for several programs. It discusses potential issues with logic, variable calculations, loop conditions, and output formatting. Suggested improvements are provided such as adding validation checks, calculating values correctly, placing lines in logical order, and fixing percentage calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views22 pages

Correcting Errors in Pseudocode

This document contains pseudocode for several programs. It discusses potential issues with logic, variable calculations, loop conditions, and output formatting. Suggested improvements are provided such as adding validation checks, calculating values correctly, placing lines in logical order, and fixing percentage calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

small should be equals to a large number in line 1.

Small = Num in line 5.

Line 7 should come after line 8 and not the opposite

Counter = 10 in line 8.
Large should be = 0 in line 1.

Counter < 30 in line 3

Num > large in line 6

Counter + 1 in line 7
Total = total + num in line 4

Remove line 5

Line 7 should come before line 6


Num > 0 in line 5

PosCount = PosCount + 1 in line 6

Line 8 should come before line 7

Print Average in line 9


Large = 0 in line 1

If Num is > large in line 5

Replace each small with large

Large = 0
Counter = 0
REPEAT
INPUT Num
IF Num > Large THEN Large = Num
Counter = Counter + 1
UNTIL Counter = 10
PRINT Large
Line 6 should be the last line

FOR Statement could be used here

A W HILE Statement could be used to checkwhether


numbers are positive or not

Total = 0
Counter = 0
FOR Counter 1 to 10
INPUT Num
Total = Total + Num
NEXT Counter
PRINT Total
Line 2

OutRange = 0

Line 6

OutRange = OutRange +1

Line 7

Should be removed

Line 8

NEXT Counter
Line 2

Counter = 0

Line 6

Num > 0

Line 7

Total = Total + Num

Line 8

Counter = Counter + 1
Line 5

Num18 = Num18 + 1

Line 8

PRINT Num18
2

Counter = 0
7

Total = Total + Number


8

Counter = Counter + 1

10

Average = Total /Counter


UNTIL Count

Count = 100

Count <--0
Sum <--0
FOR Count 1 to 100
INPUT Number
Sum <---Sum + Number
NEXT Count
PRINT Sum
2

Counter = 0

Total = Total + Number


8

Counter = Counter = 1
10

Average = Total /Counter


3

PRINT '
Enter a number between 100 and 1000',INPUT Number
4

W HILE Number =< 99 AND Number => 1001


5

PRINT '
This is incorrect,please tryagain',INPUT Number

10

PRINT Count
Line 2

W HILE Number <> 999 DO

Line 3

IF Number >= 100 THEN PRINT Number

Number is printed twice

Remove last line

INPUT Number
W HILE Number <> 999 DO
W HILE Number > 100 AND Number < 200
PRINT Number
ENDW HILE
ENDW HILE
Count

30

Total

NEXT
Line 1

Total = 000.00

Line 7 should be at the end of the program code to


increase efficiency

Line 8 should be removed

To input the height in meters of 30 students and print the average


height of these students
Line 1

Count <---0

Line 2

Total <---0

Program will calculate negative numbers in addition to positive

IF Number > 0

Total calculated incorrectly

Total <--Total + number


line 1

Count <--0

Line 3

High <---0

Line 4

Low <---10000

W rong calculation of low number

IF Number < Low


W rong calculation of over and underweight items

If ItemW eight > Over OR ItemW eight < Under

Number of rej
ected items won'
t be calculated
properly

Rej
ect <--Rej
ect + 1

Program won'
t stop at 500 items

UNTIL Count = 500

Percentage not calculated correctly

Rej
ect <---Rej
ect /Count *100
Line 6

IF Guess > Number

Line 10

IF Guess < Number

TotalTryincorrect

TotalTry<----TotalTry+ 1

Program won'
t run correctly

UNTIL Guess = Number

You might also like