Cond STMT Pseudocode
Cond STMT Pseudocode
Question:
Write a pseudocode that checks if the temperature is above 30. If yes, display “It’s hot!”
Answer:
START
INPUT temperature
ENDIF
STOP
Question:
Write pseudocode to check whether a number is even or odd.
Answer:
START
INPUT number
DISPLAY "Even"
ELSE
DISPLAY "Odd"
ENDIF
STOP
Question:
Write pseudocode to display grades based on marks:
75 to 89 → "B"
50 to 74 → "C"
Below 50 → "Fail"
Answer:
START
INPUT marks
DISPLAY "A"
DISPLAY "B"
DISPLAY "C"
ELSE
DISPLAY "Fail"
ENDIF
STOP
Question:
Write pseudocode to identify age group:
Below 13 → "Child"
13 to 19 → "Teenager"
Answer:
START
INPUT age
DISPLAY "Child"
DISPLAY "Teenager"
ELSE
DISPLAY "Adult"
ENDIF
STOP
✅ Task 5: Password Checker (IF ELSE)
Question:
Write pseudocode to check if the entered password is correct. Assume correct password is 1234.
Answer:
pgsql
CopyEdit
START
INPUT password
ELSE
ENDIF
STOP
❓ Question 1:
DISPLAY "Pass"
DISPLAY "Merit"
ELSE
DISPLAY "Fail"
Q: What is wrong with this logic? How would you fix it?
Expected Thinking: Identify ordering issues in conditions.
Sample Answer:
The conditions are in the wrong order. Once marks >= 50 is true, the program will never check if
marks >= 75. It should check the highest condition first:
sql
CopyEdit
IF marks >= 75 THEN
DISPLAY "Merit"
DISPLAY "Pass"
ELSE
DISPLAY "Fail"
❓ Question 2:
You are designing a program to check driving eligibility. The rule is:
Q: What would happen if you forget the ELSE part? Why is it important to include both branches?
Sample Answer:
If you forget the ELSE part, the program will only display a message for people who are 18 or older.
It won't show anything for people under 18. Including ELSE ensures all possible inputs are handled.
❓ Question 3:
sql
CopyEdit
DISPLAY "Excellent"
DISPLAY "Good"
Q: What will the program display if the score is 65? What is missing here?
Sample Answer:
The program will not display anything if the score is 65, because there is no ELSE condition to
handle scores 70 and below. An ELSE should be added to cover that case.