How to print out with equal spacing between columns?

For instance, my file contains the following content...

    set -A array
    set -A test
    ${array[0]}=1
    ${array[1]}=2
    ${array[2]}=3
    ${test[0]}="Boy"
    ${test[1]}="Girl"
    ${test[2]}="Dog"
    x=0
    while [ $x -lt 3 ];do
          print "${array[$x]}" " " "${test[$x]}"
          x=$((x+1)
    done 
   

As you can I have to manually control the spacing between the printing of the columns....I think I saw like

    printf "%3s %-4s" "${array[$x]}" "${test[$x]}"
     

Apparently, it isn't working as it printed out

      1Boy
      2Girl
      3Dog
       

..................
Unless I do like

     printf "%s %s" "${array[$x]}" " " " ${test[$x]}"
     

it will print out like I wanted

     1 Boy
     2 Girl
     3 Dog
     

Hi, there are some syntax errors in the sample code. Could you try this adaptation?

array=(1 2 3)  
test=(Boy Girl Dog)
x=0
while [ $x -lt 3 ]
do
  printf "%3s %-4s\n" "${array[x]}" "${test[x]}"
  x=$((x+1))
done
  1 Boy 
  2 Girl
  3 Dog