How to get post details by post id

get_post retrieve post data by post id. This is wordpress function with 3 parameters.

<?php get_post( $id, $output, $filter ); ?> 

$id : Here you will pass id of the post you would like to get data.
$output : This is optional value. Default value is OBJECT
OBJECT – (default) returns a WP_Post object
ARRAY_A – Returns an associative array of field names to values
ARRAY_N – returns a numeric array of field values
$filter: This is also an optional. It filter the post.

Example:

<?php 
$showpost=get_post( 2 ); 
$post_title=$showpost->post_title;
?>