int isPalindrome(int num){ int rev=0; int originalnum=num; while(num!=0){ rev=rev*10+num % 10; num=num/10; } if(originalnum==rev){ return 1; } else{ return 0; } } int main(){ int number; printf("enter the number\n"); scanf("%d",&number); if(isPalindrome(number)){ printf("this number is a palindrome\n"); } else{ printf("not a palindrome"); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter