PSEUDOCODE PRACTICE QUESTIONS WITH ANSWERS
Q1. Write a pseudocode that checks if a student has passed an exam. The student
passes if their score is 50 or more AND they have attended more than 75% of the
classes OR they have a medical exemption. Display "Pass" if the conditions are
met; otherwise, display "Fail."(Range Check)
OUTPUT "Enter student's score:"
INPUT score
OUTPUT "Enter student's attendance percentage:"
INPUT attendance
OUTPUT "Does the student have a medical exemption? (Yes/No)"
INPUT medicalExemption
IF (score >= 50) AND (attendance > 75) OR (medicalExemption = "Yes") THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
Q2. Write a pseudocode to check if a person is eligible for a loan. The person is
eligible if their credit score is above 700 AND they have an income over $30,000
OR they have a guarantor. Display "Eligible" if they qualify; otherwise, display
"Not Eligible.
OUTPUT "Enter credit score:"
INPUT creditScore
OUTPUT "Enter income:"
INPUT income
OUTPUT "Do you have a guarantor? (Yes/No)"
INPUT guarantor
IF (creditScore > 700) AND (income > 30000) OR (guarantor = "Yes") THEN
OUTPUT "Eligible"
ELSE
OUTPUT "Not Eligible"
ENDIF
Q3.Create a program that takes a student’s score as input and outputs their grade
according to the following criteria:
Grade: A" for scores 90 and above,
Grade: B" for scores between 80 and 89,
Grade: C" for scores between 70 and 79,
Grade: D" for scores between 60 and 69,
Grade: F" for scores below 60,
and "Invalid score" for any negative score or score above 100.
IF score >= 90 THEN
OUTPUT "Grade: A"
ELSE IF score >= 80 AND score < 90 THEN
OUTPUT "Grade: B"
ELSE IF score >= 70 AND score < 80 THEN
OUTPUT "Grade: C"
ELSE IF score >= 60 AND score < 70 THEN
OUTPUT "Grade: D"
ELSE IF score >= 0 AND score < 60 THEN
OUTPUT "Grade: F"
ELSE
OUTPUT "Invalid score"
END IF
END IF
END IF
END IF
END IF
Q4. Write a pseudocode that takes the speed of a vehicle as input and classifies it
according to the following conditions:
"Over-speeding" if the speed is above 120,
"Highway speed" if the speed is between 80 and 120,
"City speed" if the speed is between 40 and 79,
"Slow speed" if the speed is below 40,
and "Invalid speed" if the speed is negative
Code
IF speed > 120 THEN
OUTPUT "Over-speeding"
ELSE IF speed >= 80 AND speed <= 120 THEN
OUTPUT "Highway speed"
ELSE IF speed >= 40 AND speed < 80 THEN
OUTPUT "City speed"
ELSE IF speed >= 0 AND speed < 40 THEN
OUTPUT "Slow speed"
ELSE
OUTPUT "Invalid speed"
END IF
Q5. Write a pseudocode to check if the user input is a valid integer. If the input is
not an integer, display an error message.( Type check)
INPUT user_input
IF user_input is an INTEGER THEN
PRINT "Valid integer"
ELSE
IF user_input <> DIV(user_input, 1)
THEN
PRINT "Error: Input is not an integer"
END IF
END IF
Q6. Write a pseudocode to check if the user has entered any input. If the input is
blank, display an error message. (Presence Check)
Example:
INPUT user_input
IF user_input =” “ THEN
PRINT "Error: No input provided."
ELSE
PRINT "Input received."
END IF
Now make 2 Pseudocode
1)for checking password has input or not
2) for checking phone number has input or not
INPUT password
IF password = " " THEN
PRINT "Error: Password cannot be empty."
ELSE
PRINT "Password received."
END IF
INPUT phoneNumber
IF phoneNumber = " " THEN
PRINT "Error: Phone number cannot be blank."
ELSE
PRINT "Phone number received."
END IF
Q7. Write a pseudocode to Check if the user input is in a valid email format (basic
format: contains "@" and ".").( Type check)
Example:-
Date Format Check (YYYY-MM-DD)
INPUT date
IF date matches pattern "YYYY-MM-DD" THEN
PRINT "Date is in valid format."
ELSE
PRINT "Date is in invalid format."
END IF
Pseudocode:
INPUT email
IF email contains "@" AND email contains "." THEN
PRINT "Valid email format"
ELSE
PRINT "Error: Invalid email format"
END IF
Q8. Write a pseudocode to Check If hex Color Code starts with "#" and has 2-7
characters and valid hex digits (0-9, A-F). (Type check)
Hex Color Code Format Check (e.g., #FFFFFF)
INPUT hexColorCode
If hexColorCode starts with "#" AND hexColorCode has characters 2-7 are valid AND
hex digits (0-9, A-F)
Print "Hex color code is in valid format"
Else:
Print "Hex color code is in invalid format"
Q9. Write a pseudocode to Check Time Format Check (24-hour format, HH)
IF time has 5 characters AND first two characters are between "00" and "23" AND last
two characters are between "00" and "59"
THEN
OUTPUT "Time is in valid 24-hour format"
ELSE
OUTPUT "Time is in invalid format"
END IF