Q. Write the pseudocode for an algorithm to perform a double entry verification check, using the following criteria: • Input 10 numbers and store them in the array Numbers[] • Input the same 10 numbers again; as each number is input, compare it with its corresponding number in the array Numbers[] ◦ If the numbers match, move on to the next number ◦ If the numbers do not match, display both numbers and ask for the number to be re-entered ◦ store the re-entered number in the corresponding array location and move on to the next number. • When all the numbers have been checked, display a message to say the check has been completed. You do not need to declare any arrays or variables for this algorithm.
DECLARE i , index, num: INTEGER DECLARE Numbers: ARRAY [1:10] OF INTEGER OUTPUT "Enter the first 10 numbers:" FOR i ← 1 TO 10 INPUT Numbers[ i ] NEXT i OUTPUT "Re-enter the 10 numbers for verification:" FOR i ← 1 TO 10 INPUT num WHILE num <> Numbers[ i ] DO OUTPUT "Mismatch! First entry = ", Numbers[ i ], " Second entry = ", num OUTPUT "Re-enter number:" INPUT num ENDWHILE Numbers[ i ] ← num NEXT i OUTPUT "Double entry verification check completed."
The following pseudocode algorithm uses a count-controlled loop to read in 10 names and store them in the array Names[] FOR Count 1 TO 10 OUTPUT "Please enter a name" INPUT Name Names[Count] Name NEXT Count Rewrite the algorithm in pseudocode, using a condition-controlled loop instead of a count-controlled loop. Count ← 1 WHILE Count <= 10 DO OUTPUT "Please enter a name" INPUT Name Names[Count] ← Name Count ← Count + 1 ENDWHILE
The function LENGTH(X) calculates the length of a string X Write the pseudocode statements to: • read the contents of the text file Quotation.txt into an appropriate string variable that has been declared • output the string in upper case and the length of the string. DECLARE Words : STRING OPENFILE Quotation.txt FOR READ READFILE Quotation.txt, Words OUTPUT UCASE(Words), LENGTH(Words) CLOSEFILE Quotation.txt