C ++ Program to count vowels in a String

String is one of the special type of array that is array of characters. The term “String” generally means an ordered sequence of characters. In most programming language such string are enclosed in either single or double quotes.

 

#include<iostream.h>

#include<conio.h>

#include<dos.h>

void main()

{

int c,i,n;

char a[15]; //initializing array variable(for single string)

clrscr();

cout<<"\nPls Enter the Number of Characters in the string\n";

cin>>n;

cout<<"\n Enter the string";

for(i=1;i<=n;i++)

{

cin>>a[i]; //input string

}

c=0;

for(i=1;i<=n;i++) //for loop for searching vowels

{

if(a[i]=='a'||a[i]=='o'||a[i]=='e'||a[i]=='i'||a[i]=='u') //condition check with logical or operator

{

c=c+1;

}

}

cout<<"\nThe Numbers of Vowels(a,e,i,o,u) in a String is:"<<c;

sleep(10);

}

find the vowels in a string