## Check whether the Binary number is Palindrome or not

### Question:

Convert the given decimal number into binary then check whether it is Palindrome or not without using array.

## Logic:

- Get the decimal number from user.
- Convert the decimal number into binary.
- Check the first and last digit of binary number which is equal or not.
- Then remove the first and last digit of binary number.
- Repeat the step 3 and 4 until binary value becomes zero.

## Program:

#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); } }