What is Structured English in algorithm design?
A method of showing logical steps in an algorithm using straightforward English words for commands and mathematical operations.
What is a flowchart?
A diagrammatic representation of an algorithm, using symbols and flow lines to show the steps and their order.
What is an algorithm?
An ordered set of steps to be followed for completing a task.
What is pseudocode?
A representation of the logical steps in an algorithm using keywords, meaningful identifiers, and mathematical operators without adhering to a specific programming language’s syntax.
What is stepwise refinement?
The practice of breaking down a larger problem into smaller, manageable parts, and further subdividing them as needed. In program development, breaking down each step into smaller processes.
What are three common methods for writing algorithms?
What are the key features of Structured English?
Why are flowcharts effective in algorithm design?
They visually represent the structure of an algorithm, showing the sequence and relationships between steps.
How does pseudocode help in programming?
Example of Structured English Algorithm:
1 Ask for the number of values
2 Loop that number of times
3 Enter a value in the loop
4 Add the value to the total in the loop
5 Calculate and output the average
How is each step in a pseudocode algorithm typically written?
Each line of pseudocode represents a single step in the algorithm.
How should identifiers in pseudocode be written?
Name for a person’s name.What can be used to track identifiers used in pseudocode?
A pseudocode table, with the Identifier name and Description for each identifier. This helps maintain clarity and organisation.
How do you input a value in pseudocode?
Use the INPUT statement:
Syntax:INPUT <Identifier>
Example: INPUT StudentName
How do you output a message, value, or combination in pseudocode?
Use the OUTPUT statement:
Syntax: OUTPUT <…>
Examples:OUTPUT "You have made an error”OUTPUT StudentNameOUTPUT "Student name is ", StudentName
How do you assign a value to a variable in pseudocode?
Use the ‘<Identifier> ← <value>' statement.</value></Identifier>
Examples:
Counter ← 1Counter ← Counter + 1MyChar ← “A”LetterValue ← ASC(MyChar)StudentMark ← 40Percentage ← (StudentMark / 80) * 100
How can you concatenate strings in pseudocode?
Use the & operator for concatenation.
Example:
OldString ← "Your mark is”NewString ← OldString & " ninety-seven”
What are the operators used in assignment statements in pseudocode?
+: addition-: subtraction*: multiplication/: division&: string concatenation←: assignment
How do you write an IF statement for a single choice in pseudocode?
IF <Condition>
THEN
<Action>
ENDIF
Example:
IF MyValue > YourValue
THEN
OUTPUT "I win"
ENDIFHow do you write an IF statement with a single choice and an alternative in pseudocode?
IF <Condition>
THEN
<Action>
ELSE
<Alternative Action>
ENDIF
Example:
IF MyValue > YourValue
THEN
OUTPUT "I win"
ELSE
OUTPUT "You win"
ENDIFHow do you write a CASE statement for multiple choices in pseudocode?
CASE OF <Variable>
"Choice1": <Action1>
"Choice2": <Action2>
...
ENDCASE
Example:
CASE OF Direction
"N": Y ← Y + 1
"S": Y ← Y – 1
"E": X ← X + 1
"W": X ← X – 1
ENDCASEHow do you write a CASE statement with an alternative in pseudocode?
CASE OF <Variable>
"Choice1": <Action1>
"Choice2": <Action2>
...
OTHERWISE: <Alternative Action>
ENDCASE
Example:
CASE OF Direction
"N": Y ← Y + 1
"S": Y ← Y – 1
"E": X ← X + 1
"W": X ← X – 1
OTHERWISE: OUTPUT "Error"
ENDCASEWhat are the relational operators in pseudocode?
=: Equal to<>: Not equal to>: Greater than>: Less than>=: Greater than or equal to<=: Less than or equal to
How is a single-choice IF statement constructed in Python?
A colon : starts the THEN clause, and all statements in the THEN clause are indented.
Example:
myValue = int(input("Please enter my value "))
yourValue = int(input("Please enter your value "))
if myValue > yourValue:
print("I win")