Quote:
i have done it but i want to find a shorter way possible to do it.
are you sure 2 digits numbers stops at 50 ?
You start counter at 0 and then do a test to remove 0, 2, 4, 6, 8.
You are lucky you were not requested to counter 4 digits even numbers!
Think about it, what is the reason why your counter starts ar 0 ?
You do ... while loop is a little complicated, why don't you use the syntax especially made for loops with counters ?
Have read on this, it can apply to your problem with a little adaptation.
1 + 2 + 3 + 4 + ⋯ - Wikipedia[
^]