{"id":2334,"date":"2024-11-06T12:03:19","date_gmt":"2024-11-06T12:03:19","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.in\/?p=2334"},"modified":"2024-11-06T12:06:21","modified_gmt":"2024-11-06T12:06:21","slug":"enum","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2024\/11\/06\/enum\/","title":{"rendered":"Explain the enum keyword"},"content":{"rendered":"\n<p>The&nbsp;<a href=\"https:\/\/www.geeksforgeeks.org\/enumeration-enum-c\/\">enum<\/a>&nbsp;keyword is used to declare an enum (short for enumeration). An enum is a user-defined datatype, which holds a list of user-defined integer constants. By default, the value of each constant is it\u2019s index (starting at zero), though this can be changed. You can declare an object of an enum and can set it\u2019s value to one of the constants you declared before. Here is an example of how an enum might be used:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;stdio.h&gt;\nenum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun};\nint main()\n{\n  enum week day;\n  day = Thur;\n  printf(\"%d\", day);\n  return 0;\n}\n\n<strong>Output\n3<\/strong><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The&nbsp;enum&nbsp;keyword is used to declare an enum (short for enumeration). An enum is a user-defined&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/2334"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=2334"}],"version-history":[{"count":2,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/2334\/revisions"}],"predecessor-version":[{"id":2340,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/2334\/revisions\/2340"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=2334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=2334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=2334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}