Friday, February 22, 2013

C Language Example # 22 Example : Count Number of Vowels from the given string


C Language Example # 22 Example : Count Number of Vowels from the given string.

* Want to find out number of vowels from the entered string

//Written by Latest Technology Guide    
//Title : C Language Example # 22 Example : Count Number of Vowels from the given string.


#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
clrscr();
int i,vowels=0;
char ch[30];

printf("\n Enter String Character : ");
gets(ch);

printf("\n **********: Detail Description :**********\n\n");

i=0;
do
{
if(ch[i]=='a' || ch[i]=='e' || ch[i]=='i' || ch[i]=='o' || ch[i]=='u' )
vowels=vowels+1;
else if (ch[i]=='A' || ch[i]=='E' || ch[i]=='I' || ch[i]=='O' || ch[i]=='U' )
vowels=vowels+1;

i++;
}while(ch[i]!=NULL);

printf("\n\n Total Vowels in The String are : %d",vowels);

getch();
}


Output:

* Program will display number of vowels from user string.

--------------------------------------------------------------------------------
Explanation of C Programming Language Example #  22 Example : Count Number of Vowels from the given string

* using if condition, we have checked one by one character from the given string and compared with vowels, if found we are adding till the null character encountered.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

No comments:

Post a Comment