Online Compiler C

#include <stdio.h> int main() { int n; scanf("%d",&n); int count=0; while(n!=0) { int a=n%10; if(a%2==0) { count++; } n=n/10; } if(count==1) printf("YES"); else printf("NO"); return 0; }
This program reads an integer, counts how many of its digits are even, and prints "YES" if exactly one digit is even, otherwise "NO".

- The condition `count==1` checks for exactly one even digit. Think about whether the problem asks for "at least one" or "exactly one" even digit.
- The variable `a` stores each digit, but you could avoid using it and check the digit directly inside the loop.