#include<iostream>
#include<cstring>
using namespace std;
int main()
{
//variable declaration.
char str[150];
int i , vowel , cons , ch , digit , space , o ;
o = vowel = cons = ch = digit = space = 0 ;
//Take input from user.
cout<<"Enter the string:";
cin . getline ( str , 150 ) ;
//logic for th checking the blank space and cons and vowels,digits:
for( i=0 ;str[i]!='\0';++i)
{
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U')
{
++vowel;
}
else if((str[i]>='a' && str[i]<='z')||(str[i]>='A' && str[i]<='Z'))
{
++cons;
}
else if(str[i]>'0'&&cons<='9')
{
++digit;
}
else if(str[i]==' ')
{
++space;
}
}
//display output of the function that done.
cout<<"\nnumber of vowel :"<< vowel <<endl;
cout<<"\nnumber of cosonants :"<< cons <<endl;
cout<<"\nnumber of digits :"<< digit <<endl;
cout<<"\nnumber of space :"<< space <<endl;
return 0;
}
No comments:
Post a Comment