Kindly check my logic

Code = https://ide.codingblocks.com/s/229736

@7nishit
refer to this code