{"id":108,"date":"2021-09-25T09:20:31","date_gmt":"2021-09-25T09:20:31","guid":{"rendered":"https:\/\/ethosspace.com\/programmers\/?p=108"},"modified":"2021-10-11T11:50:45","modified_gmt":"2021-10-11T11:50:45","slug":"c-program-to-count-total-vowel-consonant-in-sentence","status":"publish","type":"post","link":"https:\/\/ethosspace.com\/programmers\/c-program-to-count-total-vowel-consonant-in-sentence\/","title":{"rendered":"C Program to count total vowel, consonant in sentence"},"content":{"rendered":"\n<p>This program will accept input from user. and then by iterating each character from sentence it will count number of vowel and consonant. &#8220;A&#8221;, &#8220;E&#8221;,&#8221;I&#8221;,&#8221;O&#8221;,&#8221;U&#8221; either in upper or lower case character are vowels. Other than  &#8220;A&#8221;, &#8220;E&#8221;,&#8221;I&#8221;,&#8221;O&#8221;,&#8221;U&#8221; all characters between A to Z are consonant.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Program Name: C Program to count vowel, consonant \n\n#include&lt;stdio.h&gt;\n#include&lt;string.h&gt;\n void main()\n {\n   char str&#91;50],ch; \/\/defining variable to accept input\n   int chCount=0,cCnt=0,vCount=0;\n\n    printf(\"\\n\\tEnter string to count vowel, consonant:\\t\");\n    gets(str); \/\/ Read input in \"str\" variable\n    \n\n  while (str&#91;chCount] != '\\0')\n  {\n      ch=str&#91;chCount];\n      \n   if((ch &gt;= 'a' &amp;&amp; ch &lt;= 'z') || (ch &gt;= 'A' &amp;&amp;ch &lt;= 'Z'))\n   {\n       if(ch=='a'||ch=='i'||ch=='o'||ch=='u'||ch=='e' ||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')\n\t       vCount=vCount+1;\n\t    else\n\t       cCnt=cCnt+1;\n   }\n    chCount++;\n }\n\n printf(\"\\nNumber of vowels in given sentence are :%d \\t \",vCount);\n printf(\"\\nNumber of Consonants in given sentence are : %d \\t \",cCnt);\n }<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<div class=\"wp-block-columns has-white-color has-cyan-bluish-gray-background-color has-text-color has-background is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<p>Enter string to count vowel, consonant: This is software C<br>Number of vowels in given sentence are :5<br>Number of Consonants in given sentence are : 10<\/p>\n<\/div>\n<\/div>\n\n\n\n<p>Program will read sentence in variable str. Every sentence end with &#8216;\\0&#8217; so we are iterating sentence character by character till we not receive &#8216;\\0&#8217;. as we need to increment while count manually hence we are using  chCount++;  Each character is then getting compared with vowels and then associated variable counter is also getting incremented by one.<\/p>\n\n\n\n<p>Click here for another program for vowel and consonants <a href=\"https:\/\/ethosspace.com\/programmers\/c-program-to-check-if-vowel-or-consonant\/\">https:\/\/ethosspace.com\/programmers\/c-program-to-check-if-vowel-or-consonant\/<\/a><\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>This program will accept input from user. and then by iterating each character from sentence it will count number of vowel and consonant. &#8220;A&#8221;, &#8220;E&#8221;,&#8221;I&#8221;,&#8221;O&#8221;,&#8221;U&#8221; either in upper or lower case character are vowels. Other than &#8220;A&#8221;, &#8220;E&#8221;,&#8221;I&#8221;,&#8221;O&#8221;,&#8221;U&#8221; all characters between A to Z are consonant. Output Enter string to count vowel, consonant: This is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-108","post","type-post","status-publish","format-standard","hentry","category-c-language"],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"sparkling-featured":false,"sparkling-featured-fullwidth":false,"tab-small":false},"uagb_author_info":{"display_name":"program45_-rt8nb","author_link":"https:\/\/ethosspace.com\/programmers\/author\/program45_-rt8nb\/"},"uagb_comment_info":0,"uagb_excerpt":"This program will accept input from user. and then by iterating each character from sentence it will count number of vowel and consonant. &#8220;A&#8221;, &#8220;E&#8221;,&#8221;I&#8221;,&#8221;O&#8221;,&#8221;U&#8221; either in upper or lower case character are vowels. Other than &#8220;A&#8221;, &#8220;E&#8221;,&#8221;I&#8221;,&#8221;O&#8221;,&#8221;U&#8221; all characters between A to Z are consonant. Output Enter string to count vowel, consonant: This is&hellip;","_links":{"self":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":4,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/posts\/108\/revisions\/274"}],"wp:attachment":[{"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ethosspace.com\/programmers\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}