Full Pseudocode and explanation
I appreciate the replies, though still not quite getting it.
Here is the full program pseudocode and what the text says that the program should do:
PSEUDOCODE:
Code:
Declare FullName[30] Of Characters
Declare FirstName[15], LastName[15] Of Characters
Declare FirstInitial, LastInitial As Character
Declare K, Count As Integer
Write “Enter a name with first name first: ”
Input FullName
Set Count = 1
While FullName[Count] <> “ ”
Set FirstName[Count] = FullName[Count]
Set Count = Count + 1
End While
Set FirstInitial = FullName[1]
Set LastInitial = FullName[Count+1]
For K = Count + 1 Step 1 To Length(FullName)
Set LastName[K] = FullName[K]
End For
Write LastName + “, ” + FirstName
EXPLANATION:
After the person’s full name is input, the counter-controlled While loop assigns characters in FullName to FirstName until the blank between the first and last names is encountered. At this point, the value of Count is one more than the length of FirstName, and (since the blank is character number Count) the first character in LastName is numbered Count + 1. Thus, the two assignment statements that follow the While loop correctly store the person’s initials, and the For loop copies the correct part of FullName to LastName. Finally, the Write statement, with the help of the concatenation operator +, displays the person’s name, last name first.