18.5k views
1 vote
The county clerk's office is writing a program to search their database for citizen records based on information about that citizen such as first name, last name, age, etc. Given below is a segment of pseudocode that should find the record of every citizen over the age of 50 in the county. The code makes use of the functions GetAgeOf and GetNameOf, which are used to retrieve the age and name of a citizen from a record which is inputted.

FOR EACH person IN citzlist
{
age = GetAgeOf(person)
name = GetNameOf(person) IF(age < 50)
{
DISPLAY(name)
}
There is a mistake in this pseudocode. Which of the following is the correct pseudocode to find the records of all citizens over the age of 50?

User Mamie
by
7.7k points

1 Answer

3 votes

Final answer:

The revised pseudocode corrects the conditional statement to display the names of citizens who are over the age of 50 instead of under, by using '≥' instead of '<'.

Step-by-step explanation:

The mistake in the given pseudocode is that it displays the names of citizens who are under the age of 50, rather than those who are over 50. To correct this, the conditional statement should check for ages greater than or equal to 50, and not less than 50. The corrected pseudocode to find the records of all citizens over the age of 50 is as follows:

FOR EACH person IN citzlist {
age = GetAgeOf(person)
name = GetNameOf(person)
IF(age ≥ 50) {
DISPLAY(name)
}
}

User Hleb
by
8.1k points