Showing ads in the specific category and its sub-categories

As described in codex, in_category() checks categories directly assigned to the post. That means that if a post is assigned to a child category but not to the parent, using in_category() with the parent category will fail.

Example: you have the category with ID 10, which is child of category 9. The post is assigned to category 10, not to 9. The following code will check as false because in_category() checks categories directly assigned to the post:

if( in_category( 9 ) ) {

    // ...

}

If you want check if the post belongs to category 9 or any of its childs, you could use the post_is_in_descendant_category function defined as example in the in_category documentation:

if( in_category( 9 ) || post_is_in_descendant_category( 9 ) {

    // Post belongs to category 9 or any of its childs.

}

function post_is_in_descendant_category( $cats, $_post = null ) {
    foreach ( (array) $cats as $cat ) {
        // get_term_children() accepts integer ID only
        $descendants = get_term_children( (int) $cat, 'category' );
        if ( $descendants && in_category( $descendants, $_post ) )
            return true;
    }
    return false;
}

But as I said to you in the comments, I can not know what your exact problem is with the given information.