why my code is not giving right output
Https://ide.codingblocks.com/s/267979
hi @Aditya-Kushwaha-914550392281281 since you are using the += shorthand notation, you dont need to add cnt again. The way you have written it right now, it will get added twice, and give wrong answer.
this statement will suffice.
Please mark the doubt as resolved in case of no further queries 