{"id":2753,"date":"2025-06-01T15:34:03","date_gmt":"2025-06-01T15:34:03","guid":{"rendered":"https:\/\/diznr.com\/?p=2753"},"modified":"2025-06-01T15:34:03","modified_gmt":"2025-06-01T15:34:03","slug":"type-of-c-contants-part-6","status":"publish","type":"post","link":"https:\/\/www.reilsolar.com\/pdf\/type-of-c-contants-part-6\/","title":{"rendered":"Type of C Contants- part 6"},"content":{"rendered":"<p>Type of C Contants- part 6<\/p>\n<p>[fvplayer id=&#8221;97&#8243;]<\/p>\n<h3 data-start=\"0\" data-end=\"42\"><strong data-start=\"4\" data-end=\"40\">Types of Constants in C (Part 6)<\/strong><\/h3>\n<p data-start=\"44\" data-end=\"235\">In the <strong data-start=\"51\" data-end=\"77\">C programming language<\/strong>, constants are fixed values that do not change during program execution. Constants can be classified into different types based on their data type and usage.<\/p>\n<h3 data-start=\"242\" data-end=\"272\"><strong data-start=\"246\" data-end=\"270\">1. Integer Constants<\/strong><\/h3>\n<p data-start=\"273\" data-end=\"349\">Integer constants are whole numbers (without decimal points). They can be:<\/p>\n<ul data-start=\"350\" data-end=\"547\">\n<li data-start=\"350\" data-end=\"391\"><strong data-start=\"352\" data-end=\"374\">Decimal (Base 10):<\/strong> <code data-start=\"375\" data-end=\"389\">10, 25, -100<\/code><\/li>\n<li data-start=\"392\" data-end=\"466\"><strong data-start=\"394\" data-end=\"428\">Octal (Base 8, starts with 0):<\/strong> <code data-start=\"429\" data-end=\"464\">012 (equivalent to 10 in decimal)<\/code><\/li>\n<li data-start=\"467\" data-end=\"547\"><strong data-start=\"469\" data-end=\"511\">Hexadecimal (Base 16, starts with 0x):<\/strong> <code data-start=\"512\" data-end=\"547\">0xA (equivalent to 10 in decimal)<\/code><\/li>\n<\/ul>\n<h3 data-start=\"554\" data-end=\"598\"><strong data-start=\"558\" data-end=\"596\">2. Floating-Point (Real) Constants<\/strong><\/h3>\n<p data-start=\"599\" data-end=\"683\">Floating-point constants represent decimal numbers or numbers in exponential form.<\/p>\n<ul data-start=\"684\" data-end=\"753\">\n<li data-start=\"684\" data-end=\"753\"><strong data-start=\"686\" data-end=\"698\">Example:<\/strong> <code data-start=\"699\" data-end=\"753\">3.14, -0.001, 1.2E3 (equivalent to 1.2 \u00d7 10\u00b3 = 1200)<\/code><\/li>\n<\/ul>\n<h3 data-start=\"760\" data-end=\"792\"><strong data-start=\"764\" data-end=\"790\">3. Character Constants<\/strong><\/h3>\n<p data-start=\"793\" data-end=\"854\">A <strong data-start=\"795\" data-end=\"815\">single character<\/strong> enclosed in <strong data-start=\"828\" data-end=\"851\">single quotes (&#8216; &#8216;)<\/strong>.<\/p>\n<ul data-start=\"855\" data-end=\"956\">\n<li data-start=\"855\" data-end=\"891\"><strong data-start=\"857\" data-end=\"869\">Example:<\/strong> <code data-start=\"870\" data-end=\"875\">'A'<\/code>, <code data-start=\"877\" data-end=\"882\">'5'<\/code>, <code data-start=\"884\" data-end=\"889\">'@'<\/code><\/li>\n<li data-start=\"892\" data-end=\"956\">Each character constant has an ASCII value (e.g., <code data-start=\"944\" data-end=\"949\">'A'<\/code> = 65).<\/li>\n<\/ul>\n<h3 data-start=\"963\" data-end=\"992\"><strong data-start=\"967\" data-end=\"990\">4. String Constants<\/strong><\/h3>\n<p data-start=\"993\" data-end=\"1056\">A sequence of characters enclosed in <strong data-start=\"1030\" data-end=\"1053\">double quotes (&#8221; &#8220;)<\/strong>.<\/p>\n<ul data-start=\"1057\" data-end=\"1182\">\n<li data-start=\"1057\" data-end=\"1102\"><strong data-start=\"1059\" data-end=\"1071\">Example:<\/strong> <code data-start=\"1072\" data-end=\"1081\">\"Hello\"<\/code>, <code data-start=\"1083\" data-end=\"1100\">\"C Programming\"<\/code><\/li>\n<li data-start=\"1103\" data-end=\"1182\">Stored as an <strong data-start=\"1118\" data-end=\"1141\">array of characters<\/strong> with an implicit <code data-start=\"1159\" data-end=\"1163\">\\0<\/code> (null terminator).<\/li>\n<\/ul>\n<h3 data-start=\"1189\" data-end=\"1220\"><strong data-start=\"1193\" data-end=\"1218\">5. Symbolic Constants<\/strong><\/h3>\n<p data-start=\"1221\" data-end=\"1274\">Defined using the <code data-start=\"1239\" data-end=\"1248\">#define<\/code> preprocessor directive.<\/p>\n<ul data-start=\"1275\" data-end=\"1405\">\n<li data-start=\"1275\" data-end=\"1348\"><strong data-start=\"1277\" data-end=\"1289\">Example:<\/strong>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-[5px] h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">c<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary\"><span class=\"\" data-state=\"closed\"><button class=\"flex gap-1 items-center select-none px-4 py-1\" aria-label=\"Copy\">Copy<\/button><\/span><span class=\"\" data-state=\"closed\"><button class=\"flex select-none items-center gap-1\">Edit<\/button><\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre language-c\"><span class=\"hljs-meta\">#<span class=\"hljs-keyword\">define<\/span><\/span> PI 3.14159<br \/>\n<span class=\"hljs-meta\">#<span class=\"hljs-keyword\">define<\/span><\/span> MAX_SIZE 100<br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li data-start=\"1349\" data-end=\"1405\">These are replaced by their values during compilation.<\/li>\n<\/ul>\n<h3 data-start=\"1412\" data-end=\"1446\"><strong data-start=\"1416\" data-end=\"1444\">6. Enumeration Constants<\/strong><\/h3>\n<p data-start=\"1447\" data-end=\"1516\">Created using <code data-start=\"1461\" data-end=\"1467\">enum<\/code> for defining a set of named integer constants.<\/p>\n<ul data-start=\"1517\" data-end=\"1581\">\n<li data-start=\"1517\" data-end=\"1581\"><strong data-start=\"1519\" data-end=\"1531\">Example:<\/strong>\n<div class=\"contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950\">\n<div class=\"flex items-center text-token-text-secondary px-4 py-2 text-xs font-sans justify-between rounded-t-[5px] h-9 bg-token-sidebar-surface-primary dark:bg-token-main-surface-secondary select-none\">c<\/div>\n<div class=\"sticky top-9 md:top-[5.75rem]\">\n<div class=\"absolute bottom-0 right-2 flex h-9 items-center\">\n<div class=\"flex items-center rounded bg-token-sidebar-surface-primary px-2 font-sans text-xs text-token-text-secondary dark:bg-token-main-surface-secondary\"><span class=\"\" data-state=\"closed\"><button class=\"flex gap-1 items-center select-none px-4 py-1\" aria-label=\"Copy\">Copy<\/button><\/span><span class=\"\" data-state=\"closed\"><button class=\"flex select-none items-center gap-1\">Edit<\/button><\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"!whitespace-pre language-c\"><span class=\"hljs-class\"><span class=\"hljs-keyword\">enum<\/span><\/span> <span class=\"hljs-title\">Color<\/span> {RED, GREEN, BLUE};<\/code><\/div>\n<\/div>\n<\/li>\n<\/ul>\n<p data-start=\"1588\" data-end=\"1684\" data-is-last-node=\"\" data-is-only-node=\"\">Would you like a <strong data-start=\"1605\" data-end=\"1650\">detailed explanation of any specific<\/strong><\/p>\n<h3 class=\"LC20lb MBeuO DKV0Md\"><a href=\"https:\/\/newhorizon-nhcollegkasturinagar.s3.ap-south-1.amazonaws.com\/nhc_kasturinagar\/wp-content\/uploads\/2020\/06\/12115728\/CONSTANT_VARIABLES_CHAPTER-4.pdf\" target=\"_blank\" rel=\"noopener\">CHAPTER -4 CONSTANTS ,VARIABLES AND DATA TYPES<\/a><\/h3>\n<div class=\"notranslate HGLrXd iUh30 ojE3Fb\"><\/div>\n<h3 data-start=\"1588\" data-end=\"1684\"><a href=\"https:\/\/www.rcet.org.in\/uploads\/academics\/rohini_81739848916.pdf\" target=\"_blank\" rel=\"noopener\">Type of C Contants- part 6<\/a><\/h3>\n<div class=\"hlcw0c\">\n<div class=\"MjjYud\">\n<div class=\"g Ww4FFb vt6azd tF2Cxc asEBEc\" lang=\"en\" data-hveid=\"CDUQAA\" data-ved=\"2ahUKEwi-6oW8lIGMAxXQmq8BHd_MHZkQFSgAegQINRAA\">\n<div class=\"N54PNb BToiNc\" data-snc=\"NTKp3b\">\n<div class=\"kb0PBd A9Y9g jGGQ5e\" data-snf=\"x5WNvb\" data-snhf=\"0\">\n<div class=\"yuRUbf\">\n<div class=\"b8lM7\">\n<h3 class=\"LC20lb MBeuO DKV0Md\"><a href=\"https:\/\/aravindakasukurthi.wordpress.com\/wp-content\/uploads\/2017\/08\/ctokens_chapter2.pdf\" target=\"_blank\" rel=\"noopener\">Unit-I Chapter 2 C Tokens: Character set, Identifiers, &#8230;<\/a><\/h3>\n<p>Here&#8217;s a structured and easy-to-understand explanation of:<\/p>\n<h1>\ud83d\udcbb <strong>C Programming \u2013 Types of Constants (Part 6)<\/strong><\/h1>\n<p>Suitable for <strong>BCA, B.Tech, Diploma, or beginner programmers.<\/strong><\/p>\n<hr \/>\n<h2>\ud83d\udcd8 <strong>What are Constants in C?<\/strong><\/h2>\n<blockquote><p>A <strong>constant<\/strong> is a <strong>fixed value<\/strong> that <strong>does not change<\/strong> during the execution of a program.<\/p><\/blockquote>\n<p>Constants are <strong>used in programs<\/strong> to make them more readable and maintainable.<\/p>\n<hr \/>\n<h2>\ud83d\udd39 <strong>Types of Constants in C<\/strong><\/h2>\n<p>C supports several types of constants, broadly categorized as:<\/p>\n<h3>1\ufe0f\u20e3 <strong>Integer Constants<\/strong><\/h3>\n<ul>\n<li>Whole numbers <strong>without decimal<\/strong>.<\/li>\n<li>Example: <code>10<\/code>, <code>-5<\/code>, <code>0<\/code>, <code>2000<\/code><\/li>\n<\/ul>\n<p><strong>Types:<\/strong><\/p>\n<ul>\n<li>Decimal (Base 10): <code>25<\/code><\/li>\n<li>Octal (Base 8): starts with <code>0<\/code>, e.g. <code>037<\/code><\/li>\n<li>Hexadecimal (Base 16): starts with <code>0x<\/code>, e.g. <code>0x1F<\/code><\/li>\n<\/ul>\n<hr \/>\n<h3>2\ufe0f\u20e3 <strong>Floating-point Constants<\/strong><\/h3>\n<ul>\n<li>Numbers with <strong>decimal point<\/strong> or in <strong>exponential (scientific) notation<\/strong>.<\/li>\n<li>Example: <code>3.14<\/code>, <code>-0.001<\/code>, <code>2.5e3<\/code><\/li>\n<\/ul>\n<hr \/>\n<h3>3\ufe0f\u20e3 <strong>Character Constants<\/strong><\/h3>\n<ul>\n<li>A <strong>single character<\/strong> enclosed in <strong>single quotes<\/strong> <code>' '<\/code>.<\/li>\n<li>Example: <code>'A'<\/code>, <code>'z'<\/code>, <code>'5'<\/code><\/li>\n<\/ul>\n<p>Each character constant has an <strong>ASCII value<\/strong> internally.<\/p>\n<pre><code class=\"language-c\">char ch = 'A'; \/\/ ASCII value = 65\n<\/code><\/pre>\n<hr \/>\n<h3>4\ufe0f\u20e3 <strong>String Constants<\/strong><\/h3>\n<ul>\n<li>A <strong>sequence of characters<\/strong> enclosed in <strong>double quotes<\/strong> <code>\" \"<\/code>.<\/li>\n<li>Example: <code>\"Hello\"<\/code>, <code>\"1234\"<\/code>, <code>\"C Programming\"<\/code><\/li>\n<\/ul>\n<pre><code class=\"language-c\">char str[] = \"Hello\";\n<\/code><\/pre>\n<hr \/>\n<h3>5\ufe0f\u20e3 <strong>Enumeration Constants (enum)<\/strong><\/h3>\n<ul>\n<li>Used to define <strong>named integer constants<\/strong>.<\/li>\n<li>Improves readability of code.<\/li>\n<\/ul>\n<pre><code class=\"language-c\">enum Days { MON, TUE, WED, THU, FRI };\n<\/code><\/pre>\n<p>Here, <code>MON<\/code> is 0, <code>TUE<\/code> is 1, etc.<\/p>\n<hr \/>\n<h3>6\ufe0f\u20e3 <strong>Defined Constants (<code>#define<\/code>)<\/strong><\/h3>\n<ul>\n<li>Use the <strong>preprocessor directive<\/strong> <code>#define<\/code> to create constants.<\/li>\n<\/ul>\n<pre><code class=\"language-c\">#define PI 3.14\n#define MAX 100\n<\/code><\/pre>\n<p>Once defined, <code>PI<\/code> will always be replaced with <code>3.14<\/code>.<\/p>\n<hr \/>\n<h2>\ud83e\udde0 Summary Table<\/h2>\n<table>\n<thead>\n<tr>\n<th>Constant Type<\/th>\n<th>Example<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Integer<\/td>\n<td><code>100<\/code>, <code>-23<\/code><\/td>\n<\/tr>\n<tr>\n<td>Floating-point<\/td>\n<td><code>3.14<\/code>, <code>2.0e3<\/code><\/td>\n<\/tr>\n<tr>\n<td>Character<\/td>\n<td><code>'A'<\/code>, <code>'7'<\/code><\/td>\n<\/tr>\n<tr>\n<td>String<\/td>\n<td><code>\"Hello\"<\/code><\/td>\n<\/tr>\n<tr>\n<td>Enumeration<\/td>\n<td><code>enum Colors {RED, BLUE}<\/code><\/td>\n<\/tr>\n<tr>\n<td>Defined (<code>#define<\/code>)<\/td>\n<td><code>#define PI 3.14<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>\u2705 Tips<\/h2>\n<ul>\n<li>Constants make code <strong>easier to read and maintain<\/strong>.<\/li>\n<li>Use <code>const<\/code> keyword to <strong>declare variables as constants<\/strong>:<\/li>\n<\/ul>\n<pre><code class=\"language-c\">const int age = 18; \/\/ age cannot be changed\n<\/code><\/pre>\n<hr \/>\n<p>Would you like:<\/p>\n<ul>\n<li>\ud83e\uddfe Practice questions on constants?<\/li>\n<li>\ud83d\udcc4 A PDF revision sheet?<\/li>\n<li>\ud83e\uddea A quiz to test your understanding?<\/li>\n<\/ul>\n<p>Let me know, and I\u2019ll provide it!<\/p>\n<h3><a href=\"http:\/\/gdcbeerwah.edu.in\/Files\/4506570f-d508-4426-9ccc-012bcbb608c5\/Custom\/8.0%20C%20tokens%20-%20keywords,%20identifiers,%20constants.pdf\" target=\"_blank\" rel=\"noopener\">Type of C Contants- part 6<\/a><\/h3>\n<h3 class=\"LC20lb MBeuO DKV0Md\"><a href=\"https:\/\/www.kngac.ac.in\/elearning-portal\/ec\/admin\/contents\/4_18K5MELM1_2020101608255612.pdf\" target=\"_blank\" rel=\"noopener\">Programming in C with Numerical Methods Unit I Chapter II &#8230;<\/a><\/h3>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Type of C Contants- part 6 [fvplayer id=&#8221;97&#8243;] Types of Constants in C (Part 6) In the C programming language, constants are fixed values that do not change during program execution. Constants can be classified into different types based on their data type and usage. 1. Integer Constants Integer constants are whole numbers (without decimal [&hellip;]<\/p>\n","protected":false},"author":71,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[97],"tags":[],"class_list":["post-2753","post","type-post","status-publish","format-standard","hentry","category-c-programming"],"_links":{"self":[{"href":"https:\/\/www.reilsolar.com\/pdf\/wp-json\/wp\/v2\/posts\/2753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.reilsolar.com\/pdf\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.reilsolar.com\/pdf\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.reilsolar.com\/pdf\/wp-json\/wp\/v2\/users\/71"}],"replies":[{"embeddable":true,"href":"https:\/\/www.reilsolar.com\/pdf\/wp-json\/wp\/v2\/comments?post=2753"}],"version-history":[{"count":0,"href":"https:\/\/www.reilsolar.com\/pdf\/wp-json\/wp\/v2\/posts\/2753\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.reilsolar.com\/pdf\/wp-json\/wp\/v2\/media?parent=2753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.reilsolar.com\/pdf\/wp-json\/wp\/v2\/categories?post=2753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.reilsolar.com\/pdf\/wp-json\/wp\/v2\/tags?post=2753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}