Please Check my code

Am not getting the correct o/p as prateek bhaiya got