Check whether the Binary number is Palindrome or not

Question:
Convert the given decimal number into binary number then check whether it is Palindrome or not without using an array.
Logic:
- Get the decimal number from the user.
- Convert the decimal number into binary.
- Check the first and last digit of binary which is equal or not.
- Then remove the first and last digit of the binary.
- Repeat steps 3 and 4 until the binary value becomes zero.
Binary Number
A Binary is made up of only 0s and 1s. There is no 2, 3, 4, 5, 6, 7, 8, or 9 in Binary!.
About Binary More>>
Program:
[code lang=”c”]
#include<stdio.h>
void main()
{
int n,i=0,j=1,k=0,m=1;
printf("Enter the number");
scanf("%d",&n);
while(n>0) //converts decimal to binary
{
k=k+(n%2)*m;
m*=10;
n/=2;
}n=k;
m/=10;
while(k>0)
{
i=k/m; //first digit of binary number
j=k%10; //last digit of binary number
if(i!=j) //check both first and last digit
break;
k%=m; //removes the first digit
k/=10; //removes the last digit
m/=100;
}
if(k==0)
{
printf("%d is Palindrome", n);
}
else
{
printf("%d is not palindrome",n);
}
}
[/code]