
{"id":15877,"date":"2014-06-23T21:41:52","date_gmt":"2014-06-23T21:41:52","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=15877"},"modified":"2014-06-23T21:41:52","modified_gmt":"2014-06-23T21:41:52","slug":"how-to-write-a-program-to-find-if-a-number-is-a-power-of-2","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2014\/06\/23\/how-to-write-a-program-to-find-if-a-number-is-a-power-of-2\/","title":{"rendered":"How to write a program to find if a number is a power of 2 ?"},"content":{"rendered":"<pre>\n\/* determining if an integer is a power of 2 *\/\n#include &lt;stdio.h&gt;\n\nint main()\n{\n\nunsigned int v; \/* we want to see if v is a power of 2 *\/\n\ntypedef int bool;\nbool f;\n\nprintf(\"enter number\");\nscanf(\"%d\",&amp;v);\nf = ( v &amp; ( v - 1) ) == 0;\nprintf(\"the result is %d \\n\",f);\n\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/* determining if an integer is a power of 2 *\/ #include &lt;stdio.h&gt; int main() { unsigned int v; \/* we want to see if v is a power of 2 *\/ typedef int bool; bool f; printf(&#8220;enter number&#8221;); scanf(&#8220;%d&#8221;,&amp;v); f = ( v &amp; ( v &#8211; 1) ) == 0; printf(&#8220;the result is &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2014\/06\/23\/how-to-write-a-program-to-find-if-a-number-is-a-power-of-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to write a program to find if a number is a power of 2 ?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[141,78,91],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15877"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=15877"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15877\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=15877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=15877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=15877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}