#include <stdio.h>
int main() {
int n,i=1;
scanf("%d", &n);
while(n>9){
int digit1=n%10;
int digit2=(n/10)%10;
if(digit1=digit2){
printf("YES\n");
return 0
}
n=n/10
}
printf("NO");
return 0;
}
The code reads an integer `n` and checks if any two adjacent digits in the number are equal. It loops by repeatedly removing the last digit and comparing the last two digits. If a pair of equal adjacent digits is found, it prints "YES" and stops; otherwise, after the loop ends, it prints "NO".
- In the `if` condition, you used `digit1=digit2` which is an assignment, not a comparison. Use `==` for equality comparison.
- You are missing semicolons after `return 0` and `n=n/10`. Add semicolons to complete those statements.