#include <stdio.h>
int main() {
int n,sum;
scanf("%d",&n);
while(n>9){
int digit1=n%10;
int digit2=(n/10)%10;
sum=digit1+digit2;
if(digit1==digit2){
printf("%d/n",sum);
}
n=n/10;
}
return 0;
}
This code reads an integer, then repeatedly extracts the last two digits, checks if they are equal, and prints their sum if they are. It then removes the last digit and continues until the number is less than 10.
- The condition `digit1==digit2` checks if the last two digits are equal, but the problem likely expects you to check all pairs of adjacent digits in the number, not just the last two. Your loop only compares the last two digits each time, not all adjacent pairs.
- The `printf` inside the loop prints the sum each time a matching pair is found, but you may need to print only once after processing all digits, or handle the output differently depending on the task. Also, note that `/n` should be `\n` for a newline.