how to get the assigned child term of the term’s parent

This should work

<?php
    if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) :
      foreach( $terms as $term) :
        if ($term->parent != 0){
          echo $term->name;
        }
      endforeach;
    endif;
?>

In the loop of the terms it prints only terms that have a ‘parent term’ given by $term->parent!=0 which means that the term is a child.

error code: 523