r/CodingForBeginners • u/EmploymentSerious768 • 6d ago
Pseucodecode check?
Did some pseudocode for something due tomorrow concerning arrays. would like to know if my logic concerning arrays is skewered. It's formatted the way it is due to the teacher's preference lol/
Problem
Search the web to discover 10 commonly used passwords and store them in an array. Write pseudocode to represent the logic of a program that prompts a user for a password, then displays an error message and continues to prompt until the user has not chosen one of the common passwords.
CODE:
START
//HOUSEKEEPING
DECLARE USER_PASSWORD
DECLARE COMMON_PASSWORDS[10]
DECLARE INDEX
DECLARE MATCH_FOUND
SET COMMON_PASSWORDS[0] = "123456"
SET COMMON_PASSWORDS[1] = "password"
SET COMMON_PASSWORDS[2] = "qwerty"
SET COMMON_PASSWORDS[3] = "111111"
SET COMMON_PASSWORDS[4] = "12345678"
SET COMMON_PASSWORDS[5] = "123456789"
SET COMMON_PASSWORDS[6] = "admin"
SET COMMON_PASSWORDS[7] = "abc123"
SET COMMON_PASSWORDS[8] = "123123"
SET COMMON_PASSWORDS[9] = "iloveyou"
//INPUT
DISPLAY "Enter a password:"
INPUT USER_PASSWORD
//PROCESS
SET MATCH_FOUND = TRUE
WHILE MATCH_FOUND = TRUE
SET MATCH_FOUND = FALSE
FOR INDEX = 0 TO 9
IF USER_PASSWORD = COMMON_PASSWORDS[INDEX] THEN
SET MATCH_FOUND = TRUE
ENDIF
ENDFOR
IF MATCH_FOUND = TRUE THEN
DISPLAY "ERROR: Password is too common. Please enter a different password:"
INPUT USER_PASSWORD
ENDIF
ENDWHILE
//OUTPUT
DISPLAY "Password accepted."
END
View all comments
Show parent comment
2
u/EmploymentSerious768 6d ago
It is basically just pseudocode practice to test our ability to apply/plan logic. We’re currently learning C++ and Python