slug
type
status
category
date
summary
tags
password
icon
Here are the 100 basic pseudocode questions:
1. Variables and Constants
- What is the keyword used to declare a variable in pseudocode?
- How would you declare a variable
Counterof typeINTEGER?
- What operator is used for assignment in pseudocode?
- Write an example of assigning the value
10to a variable namedTotal.
- How do you declare a constant named
PIwith a value of3.14?
2. Data Types
- Name five basic data types supported in pseudocode.
- Write an example of declaring a
BOOLEANvariable calledIsComplete.
- What data type is used to store the value
"Hello World"?
- How is a character stored in pseudocode?
- Write an example of a
DATEtype declaration.
3. Arrays
- How would you declare a one-dimensional array of size 10 storing
INTEGERvalues?
- How would you access the third element in the array
Numbers?
- Write a statement to assign the value
5to the second element of an arrayScores.
- Can arrays be multi-dimensional? Write an example.
- How would you iterate over all elements in a one-dimensional array
Valuesof size 5?
4. Conditional Statements
- What is the structure of an
IFstatement in pseudocode?
- How do you write an
IFstatement with anELSEclause?
- Write an
IFstatement to check ifScore > 50and output "Pass".
- How is a
CASEstatement structured?
- Write a
CASEstatement for a variableChoiceto handle values1,2, andOTHERWISE.
5. Loops
- How is a
FORloop structured in pseudocode?
- Write a
FORloop to output numbers 1 to 5.
- How is a
WHILEloop written in pseudocode?
- Write a
WHILEloop to keep doubling a numberXwhile it is less than 100.
- How does a
REPEATloop differ from aWHILEloop?
6. Procedures
- How do you define a procedure in pseudocode?
- Write a procedure
Greetthat outputs "Hello".
- How do you call a procedure named
DisplayMessage?
- How can parameters be passed to a procedure?
- Write a procedure
Squarethat calculates and outputs the square of a number passed as a parameter.
7. Functions
- How do you define a function in pseudocode?
- Write a function
Addthat takes two integers and returns their sum.
- How is a function called in pseudocode?
- What is the difference between a procedure and a function?
- Write a function
IsEventhat returnsTRUEif a number is even, otherwiseFALSE.
8. File Handling
- How do you open a text file for reading in pseudocode?
- How do you write data to a text file?
- Write an example of reading a line from a file named
InputFile.
- How can you check if the end of a file has been reached?
- Write pseudocode to copy all lines from
FileAtoFileB.
9. Logical and Relational Operations
- What are the relational operators in pseudocode?
- Write a condition to check if
Xis between 10 and 20.
- What are the logical operators in pseudocode?
- How would you negate the condition
X > 5?
- Write a condition to check if a number is either less than 5 or greater than 10.
10. String Operations
- How do you get the length of a string in pseudocode?
- Write an example to extract the first three characters of a string
Name.
- How do you concatenate two strings
FirstNameandLastName?
- Write pseudocode to convert a character
Ato lowercase.
- How do you get the rightmost 5 characters of a string
Word?
11. Object-Oriented Programming
- How do you define a class in pseudocode?
- Write a simple class definition for a
Dogwith a propertyNameand a procedureBark.
- How do you create an object of a class
Car?
- How is inheritance denoted in pseudocode?
- Write a constructor for a class
Personthat initializes aNameproperty.
12. Variables and Identifiers
- What are the rules for naming identifiers in pseudocode?
- Write an example of declaring a variable with a meaningful name.
- What is the purpose of using meaningful identifier names?
- Can keywords like
IForWHILEbe used as identifiers?
- How do you declare multiple variables of the same data type in one line?
13. Assignments and Operations
- What does the assignment
X ← X + 1do?
- Write an example of a compound assignment using arithmetic operations.
- Which operator is used for integer division?
- Write a pseudocode statement to calculate the remainder of
Adivided byB.
- How do you ensure clarity in complex arithmetic expressions?
14. Arrays
- How do you declare a two-dimensional array of size 3x3 to store characters?
- Write a statement to assign the value
'X'to the middle cell of a 3x3 arrayBoard.
- How would you iterate over all elements in a two-dimensional array
Matrix?
- Can you assign one array to another directly?
- How do you initialize all elements of a one-dimensional array to a default value?
15. Selection Statements
- What is the purpose of an
ELSEclause in anIFstatement?
- Write an
IFstatement to check if a variableAgeis greater than or equal to 18.
- How do you handle multiple conditions using nested
IFstatements?
- When should you use a
CASEstatement instead of anIFstatement?
- Write a
CASEstatement for a variableDayto output the name of the day for1(Monday) to7(Sunday).
16. Iteration
- What is the difference between a
WHILEloop and aREPEATloop?
- Write a
FORloop to calculate the sum of integers from 1 to 10.
- How do you terminate a loop prematurely in pseudocode?
- Write a
WHILEloop to halve a numberNuntil it becomes less than 1.
- Write a
REPEATloop to repeatedly ask for input until a valid password is entered.
17. File Handling
- How do you open a file for appending data in pseudocode?
- How can you replace blank lines in a text file with a line of dashes?
- Write pseudocode to check if a file is empty.
- How do you move the file pointer to a specific position in a random access file?
- Write pseudocode to read a record from a random file and output its contents.
18. Object-Oriented Programming
- What keyword is used to inherit from a parent class?
- How do you define a private property in a class?
- Write an example of calling a superclass method from a subclass.
- How do you create an object of class
Studentwith a constructor that takesNameas a parameter?
- Write an example of a method in a class that calculates and returns the area of a rectangle.
19. Best Practices
- Why should variables be declared explicitly in pseudocode?
- What is the benefit of using constants instead of literals?
- How can indentation improve the readability of pseudocode?
- Why should you avoid deeply nested loops?
- When is it appropriate to use comments in pseudocode?
20. Miscellaneous
- What symbol is used to indicate comments in pseudocode?
- Write an example of a single-line comment.
- What is the purpose of the
RETURNstatement in functions?
- How can you specify that a parameter should be passed by reference?
- Write pseudocode for swapping the values of two variables
AandB.
Think about the questions below and check the answers one by one:
Q1:What is the keyword used to declare a variable in pseudocode?
Answers:
DECLARE is used to declare a variable.Q2:How would you declare a variable Counter of type INTEGER?
Answers:
DECLARE Counter : INTEGERQ3:What operator is used for assignment in pseudocode?
Answers:
Q3: What operator is used for assignment in pseudocode?
A3: The operator is
←.Q4:Write an example of assigning the value 10 to a variable named Total.
Answers:
Q4: Write an example of assigning the value
10 to a variable named Total.A4:
Total ← 10Q5:How do you declare a constant named PI with a value of 3.14?
Answers:
Q5: How do you declare a constant named
PI with a value of 3.14?A5:
CONSTANT PI = 3.14Q6:Name five basic data types supported in pseudocode.
Answers:
Q6: Name five basic data types supported in pseudocode.
A6:
INTEGER, REAL, CHAR, STRING, BOOLEAN.Q7:Write an example of declaring a BOOLEAN variable called IsComplete.
Answers:
Q7: Write an example of declaring a
BOOLEAN variable called IsComplete.A7:
DECLARE IsComplete : BOOLEANQ8:What data type is used to store the value "Hello World"?
Answers:
Q8: What data type is used to store the value
"Hello World"?A8:
STRING.Q9:How is a character stored in pseudocode?
Answers:
Q9: How is a character stored in pseudocode?
A9: It is stored in single quotes, e.g.,
'A'.Q10:Write an example of a DATE type declaration.
Answers:
Q10: Write an example of a
DATE type declaration.A10:
DECLARE Today : DATEQ11:How would you declare a one-dimensional array of size 10 storing INTEGER values?
Answers:
Q11: How would you declare a one-dimensional array of size 10 storing
INTEGER values?A11:
DECLARE Numbers : ARRAY[1:10] OF INTEGERQ12:How would you access the third element in the array Numbers?
Answers:
Q12: How would you access the third element in the array
Numbers?A12:
Numbers[3]Q13:Write a statement to assign the value 5 to the second element of an array Scores.
Answers:
Q13: Write a statement to assign the value
5 to the second element of an array Scores.A13:
Scores[2] ← 5Q14: Can arrays be multi-dimensional? Write an example.
Answers:
Q14: Can arrays be multi-dimensional? Write an example.
A14: Yes, arrays can be multi-dimensional. Example:
DECLARE Grid : ARRAY[1:3, 1:3] OF CHARQ15:How would you iterate over all elements in a one-dimensional array Values of size 5?
Answers:
Q15: How would you iterate over all elements in a one-dimensional array
Values of size 5?A15:
Q16:What is the structure of an IF statement in pseudocode?
Answers:
Q16: What is the structure of an
IF statement in pseudocode?A16:
Q17:How do you write an IF statement with an ELSE clause?
Answers:
Q17: How do you write an
IF statement with an ELSE clause?A17:
Q18:Write an IF statement to check if Score > 50 and output "Pass".
Answers:
Q18: Write an
IF statement to check if Score > 50 and output "Pass".A18:
Q19:How is a CASE statement structured?
Q20:Write a CASE statement for a variable Choice to handle values 1, 2, and OTHERWISE.
Answers:
Q20: Write a
CASE statement for a variable Choice to handle values 1, 2, and OTHERWISE.A20:
Q21: How is a FOR loop structured in pseudocode?
Answers:
Q21: How is a
FOR loop structured in pseudocode?A21:
Q22: Write a FOR loop to output numbers 1 to 5.
Answers:
Q22: Write a
FOR loop to output numbers 1 to 5.A22:
Q23:How is a WHILE loop written in pseudocode?
Answers:
Q23: How is a
WHILE loop written in pseudocode?A23:
Q24:Write a WHILE loop to keep doubling a number X while it is less than 100.
Answers:
Q24: Write a
WHILE loop to keep doubling a number X while it is less than 100.A24:
Q25: How does a REPEAT loop differ from a WHILE loop?
Answers:
Q25: How does a
REPEAT loop differ from a WHILE loop?A25: A
REPEAT loop executes its statements at least once before checking the condition.- 作者:现代数学启蒙
- 链接:https://www.math1234567.com/article/bpq1
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。






