Isn't the idea same as palindrome but instead of checking the same characters you will have to check the below map
[6, 9]
[9, 6]
If the number encountered is 6 then at the other end it should have 9 and vice versa.
#include <stdio.h>
#include <math.h>
long rotate180(long x){
long q, r, y=0,c=0;
q=x;
while(q>;0){
r=q%10;
q=q/10;
if(r!=8 && r!=0 && r!=1 && r!=6 && r!=9)
return 0;
if(r==6)r=9;
else if(r==9)r=6;
y=r+y*(10);
}
printf("y is set to: '%lld'\n",y);
return y;
}
int main()
{
long n=99166;
long r=rotate180(n);
if(r!=0 && r==n)
printf("They are equal after 180 degree rotation\n");
else
printf("Failed");
return 0;
}