Professional Documents
Culture Documents
091158o57471516101612 PLT KB 01 2
091158o57471516101612 PLT KB 01 2
Collaborate
The programmer should decide on the expected output before writing an algorithm.
These statements make the pseudocode lengthy because they are written on separate
lines. Therefore, the statements can be combined, as given below:
display Enter three numbers
accept number1, number2, number3
The pseudocode should be correctly aligned for a clear understanding of the steps.
For example, consider the following pseudocode snippet:
begin
:
:
:
display Enter your name
accept name
display Enter your age
NIIT
accept age
if age is greater than 18
display Candidate can have a driving license
else
display Candidate cannot have a driving license
:
:
:
end
The statements in the preceding pseudocode are not aligned correctly. To ensure
readability, the statements must be aligned, as shown below:
begin
:
:
:
display Enter your name
accept name
display Enter your age
accept age
if age is greater than 18
display Candidate can have a driving license
else
display Candidate cannot have a driving license
:
:
:
end
NIIT
Challenge
Problem Statement 1
Vaccination camps need to be organized to provide free vaccination to children below
five years of age. To organize these vaccination camps, a population survey needs to be
conducted. This will help the hospital staff to determine the approximate number of
vaccines that should be supplied to the camps. Children who are below the age of five
years, do not have any disease, and are born in families below the poverty line will be
given free vaccinations. Families that have an annual income of less than $4500 will be
assumed to be below the poverty line.
Represent the algorithm of the given problem statement, using pseudocode.
Problem Statement 2
As part of a publicity campaign, Arizona Institute of Geology needs to publish its
students performance results along with the average percentage for the top five students
in an educational magazine. The top five engineering students of the institute scored 99,
97, 96, 95, and 94 percent in their semester examinations. The following pseudocode
partially represents the algorithm for this problem. Complete the pseudocode.
begin
display The average is
average = (nScore1+nScore2+nScore3+nScore4+nScore5)/5
display nAverage
end
Problem Statement 3
A teacher at the RiverDale school conducts a mathematics test for three students: Marc,
Alex, and John. She needs to compare the score of the three students and display the name
of the student scoring the highest score. The following pseudocode partially represents the
logic to solve the problem. Complete this pseudocode.
begin
numeric
display
accept
display
accept
display
NIIT
accept
end
nScore3
Problem Statement 4
The management of Heritage Company decides to provide House Rent Allowance (HRA)
to its employees. The criteria for calculating the HRA amount is:
If the basic salary of an employee is greater than $10,000, the HRA given to the
employee will be 30 percent of the basic salary.
If the basic salary of an employee is equal to or less than $10,000, the HRA given to
the employee will be 20 percent of the basic salary.
Complete the following algorithm for the problem:
Problem Statement 5
Brilliants University displays the final results of the examinations on their Web site. To
view the results, students need to enter their roll numbers at the Web site. If a student
scores more than 50 percent, the result is displayed as Passed, along with the marks.
Otherwise, the result is displayed as Failed. The following pseudocode is created to
represent the algorithm. However, the pseudocode has errors in it. Correct the
pseudocode.
begin
display Enter your roll number
accept StudentRollNumber
display StudentRollNumber and Passed
if student score is less than 50%
display StudentRollNumber and Failed
end
NIIT
Problem Statement 6
A bookstore is offering a discount on books. The books are divided into two categories, A
and B. The discount is only for the books in category A. If a customer buys a book from
category A, a discount of 10 percent is provided.
Complete the pseudocode given below to represent this algorithm:
begin
display Enter the category of book purchased
accept the category of book
end
NIIT
Home Assignment
1.
In the instruction MULTIPLY A AND B, which of the following option specifies the
opcode?
a. MULTIPLY
b. A
c. AND
d. B
2.
Which of the following construct has a testing statement at the bottom of the iterative
set of statements?
a. ifelseendif
b. dowhile
c. whiledo
d. fornext
3.
Which of the following statement is used to exit from the case after the condition is
met and the case statements are executed?
a. Switch statement
b. Break statement
c. Default statement
d. Execute statement
4.
Which of the following sequence of steps will help you display the sum of two
numbers?
a. 1. Get the First Number
2. Display the Result
3. Stop
4. Add the Two Numbers
5. Get the Second Number
6. Start
b. 1. Get the First Number
2. Display the Result
3. Add the Two Numbers
4. Get the Second Number
5. Stop
6. Start
NIIT
c. 1.
2.
3.
4.
5.
6.
d. 1.
2.
3.
4.
5.
6.
Start
Get the First Number
Get the Second Number
Add the Two Numbers
Display the Result
Stop
Get the First Number
Display the Result
Add the Two Numbers
Stop
Get the Second Number
Start
5.
Which of the following operator is used to check if two numbers are not equal?
a. !=
b.
c. <>
d. NOT
6.
Jim has started writing a pseudocode for finding the factorial of a number. Which of
the following keyword will he use to give additional information about each step in
the pseudocode?
a. //
b. display
c. accept
d. compute
7.
Which of the following conditional execution construct is used for executing the
statements if the condition is true?
a. if construct
b. ifelse construct
c. nested ifelse construct
d. switchcase construct
8.
NIIT
9.
NIIT