{"id":784,"date":"2021-10-30T04:53:08","date_gmt":"2021-10-30T04:53:08","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=784"},"modified":"2021-10-30T04:53:09","modified_gmt":"2021-10-30T04:53:09","slug":"program-to-identify-and-print-perfect-number-in-c-language","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/program-to-identify-and-print-perfect-number-in-c-language\/","title":{"rendered":"Program to identify and print perfect number in C Language"},"content":{"rendered":"\n<p>This C Program is for to identify perfect number. Here program is accepting range up to which need to identify perfect number. Perfect number is \u00a0a\u00a0perfect number\u00a0is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. for example 6 where it is divisible for 1, 2, 3 so sum of it is 6. To write this program we have used two for loop along with simple if condition.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-c\" data-lang=\"C\"><code>\/\/ Program to find perfect number\n#include &lt;stdio.h&gt;\n\nint main() {\n    \/\/ Write C code here\n    int rangeNo,counterNo,perSum;\n  \n    printf(&quot;\\n\\tEnter Range to find perfect number \\t&quot;);\n    scanf(&quot;%d&quot;,&rangeNo);\n   \/\/Loop to find divisible numbers \n\n    for (int i = 1;i&lt;=rangeNo;i++)\n    {\n        perSum=0;\n          for (int j = 1;j&lt;i;j++)\n            {\n                if (i%j == 0)\n                perSum = perSum + j;\n             }\n            if (perSum == i)\n            printf(&quot;\\n\\t %d is perfect number &quot;,i);\n    }\n    return 0;\n}<\/code><\/pre><\/div>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>Enter Range to find perfect number \t10000\n6 is perfect number \n28 is perfect number \n496 is perfect number \n8128 is perfect number <\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This C Program is for to identify perfect number. Here program is accepting range up to which need to identify perfect number. Perfect number is \u00a0a\u00a0perfect number\u00a0is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. for example 6 where it is divisible for 1, 2, 3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-784","post","type-post","status-publish","format-standard","hentry","category-c-language"],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"sparkling-featured":false,"sparkling-featured-fullwidth":false,"tab-small":false},"uagb_author_info":{"display_name":"program45_-rt8nb","author_link":"https:\/\/ethosspace.com\/programmers\/author\/program45_-rt8nb\/"},"uagb_comment_info":0,"uagb_excerpt":"This C Program is for to identify perfect number. Here program is accepting range up to which need to identify perfect number. Perfect number is \u00a0a\u00a0perfect number\u00a0is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. for example 6 where it is divisible for 1, 2, 3&hellip;","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/comments?post=784"}],"version-history":[{"count":2,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/784\/revisions"}],"predecessor-version":[{"id":786,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/784\/revisions\/786"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}