This C program to count number of vowels and consonants in an entered string. Here variables " v mean vowel " is increment whenever is a vowel found in tracing otherwise " c mean consonant " is increment .
Program :
Output :
Program :
#include<stdio.h> #include<conio.h> void main() { char ch; do{ char s[100]; int i,v=0,c=0; clrscr(); printf("\n Enter a string :"); gets(s); for(i=0;s[i]!=NULL;i++) { if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'|| s[i]=='A'||s[i]=='E'||s[i]=='I'||s[i]=='O'||s[i]=='U') { v++; } else { if(s[i]!=' '||s[i]!='.') c++; } } printf("\n The total number of vowel is[%d] and consonants is [%d] ",v,c); printf("\n Continue (y/n):"); ch=getch(); }while(ch=='y'||ch=='Y'); }
Output :
If you have any Further Information and Quires about this Article don't hesitate to comment in comment box below.
AND
If you like this article , like our Facebook like page and click +1 to support 123techguide
|