Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]

As I noted in the comments, this is more a programming language question than a WordPress Development question, and that goes for the second question, too. However, instead of adding to comment discussion and making more mistakes, I’ll write out an answer.

function slider_news() {

    $num = 0;
    $args = array( 'numberposts' => 3 );

    $latest_posts = get_posts( $args );   

    foreach ( $latest_posts as $post ) {

        $num++; //PHP increment operator ++ (add 1 to value)

        if ( 1 === $num ) { //using a single equals as in original would set the value, === is strict equivalence

            echo 'Post with <div class="active">1st Post</div>';
            //example was missing final ">"

        } else {

            echo 'Post with <div class="Normal">All other posts except 1st</div>';

        }

    }

}

I don’t see any problem in the above with alternating between single and double quotes. As long as you you are consistent with using single quotes to set off strings, you can use double quotes within them however you like, but you will need to escape single quotes meant to be printed. For more, I suggest you read up on PHP syntax. There aren’t any special WordPress exceptions to be concerned with.