4.3 Solutions

    1. for count : 1 .. 9
         for i : 1 .. count
         	put " "..
         end for
         put "*"
      end for
    2. for decreasing i : 4 .. 1
         put i**2
      end for 

  1. const PASSWORD := "Something Impossible to Guess"
    var guess : string
    var tries : int := 0
    
    loop
       put "Enter password"
       get guess:*
       tries := tries + 1
       exit when tries = 3 or guess = PASSWORD
    end loop
    
    if guess = PASSWORD then
       put "Welcome to the system"
    else
       put "ACCESS DENIED! Go away."
    end if 

  2.  
    % Assuming Only Valid Characters

    var num : int loop put "Enter a positive integer less than 1000" get num exit when num > 0 and num < 1000 put "That was an invalid input." if num <= 0 then put "You need a larger number." else put "You need a smaller number." end if end loop

    % Error Proof Version

    var num : int var input : string loop loop put "Enter a positive integer less than 1000" get input:* exit when strintok(input) put "Please enter a valid integer" end loop num := strint(input) exit when num > 0 and num < 1000 put "That was an invalid input." if num <= 0 then put "You need a larger number." else put "You need a smaller number." end if end loop