For block A apply Newton’s second law of motion along the inclined and for block B apply Newton’s second law along the horizontal.
Both the blocks A and B are considered as two independent systems. The FBDs for the blocks A and B are shown in the Figure and
Figure where T is tension in the string.
Now, by adding equations (i) and (iii), we obtain