help in fixing this code..
i need to write a code that flips a number and sums it with the previous form of the number,till i get a number that if i will flip it
i will get the same number
i need to output the number of steps which took the program to transform the input number into the number that if we flip it ,it will remain the same.
for example if i input
679 + 976 = 1655
1655 + 5561 = 7216
7216 + 6127 = 13343
13343 + 34331 = 47674
4 steps
i wrote the code which flips i put a loop over it but its not working
??
Code:
int main(){
int sum=0;
int counter=0;
int i;
int n = 0;
scanf("%d",&i);
counter=0;
while(n!=i) {//start while
while(i)
{
n = 10 * n + i % 10;
i /= 10;
}
n=i+n;
counter++;
}//end while
printf("%d %d",n,counter);
return 0;
}