/* Problem 2 There is a treasure chest with 1 million dollars. The chest has a 4-digit combination lock that opens under the following conditions: the first digit must be even, the second and third digits must be the same, and the last digit must be divisible by 3 Write a program that reads ONE 4-digit positive integer and checks whether the input number opens the chest or not. The output should be YES, if the chest opens, and NO otherwise. The program must check validity of the input. If the inputs is not a 4-digit positive integer, the program must print the error message. Example 1: if the inputs is 2224 the output is NO Example 2: if the input is 4229 the output is YES */ #include int main(){ int num,d1,d2,d3,d4; printf("enter 4-digit number \n"); scanf("%d",&num); if(num>=1000 && num<=9999){ d4=num%10; num=num/10; d3=num%10; num/=10; d2=num%10; num/=10; d1=num%10; if(d1%2==0 && d2==d3 && d4%3==0) printf("YES\n"); else printf("NO\n"); } else printf("invalid input\n"); return 0; }