Use this code snippet to display the first category of a WordPress post.
<?php
$smello = (array) get_the_category($post_ID])[0];
echo $smello['cat_name'];
?>
where $post_ID is the ID of the post whose category is required.
Change [0] to [1] to get the second category. Not all posts will have a second category, so you will have to check if its empty or not before using it.
thank you for sharing this information it will help full for us