In printing even no. here if we gave value of a =5 then it is also printing 5 with other results how we solve this

#include
using namespace std;
int main() {
int a;
cout << "Enter the digit: " << std::endl;
cin >> a;

if (a % 2 != 0) {
    a = a - 1;
}

while (a >= 0) {
      cout << a << std::endl;
    a = a - 2;
}

return 0;

}

The issue is a >= 0 includes zero; change to a > 0 to avoid printing zero.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.