Algorithm Analysis
In the variable flag, we will count the number of conditions met. Initially, we set flag = 0.
If the number n is even, then we increase flag by 1;
If the number n is negative and divisible by three, then we increase flag by 1;
If flag = 1, then exactly one condition is met, we print YES. Otherwise, we print NO.
Example
Let n = 22. The number is even. The number is not negative and divisible by 3. Only one condition is met.
Algorithm Implementation
Read the input number n.
scanf("%d", &n);
Check the two conditions. If a condition is met, then we increase flag by 1.
flag = 0; if (n % 2 == 0) flag++; if (n < 0 && n % 3 == 0) flag++;
Depending on the value of the variable flag, we print the corresponding answer.
if (flag == 1) puts("YES"); else puts("NO");