/*PROGRAM TO COUNT NO. OF VOWELS, CONSONANTS, SPACES AND WORDS IN A STRING ENTERED BY A USER*/
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
class counts
{
int c,v,s,w,i;
char a[15];
public:
void process();
};
void counts::process()
{
cout<<“Enter any string: “;
gets(a);
i=0;
c=0;
v=0;
s=0;
w=1;
while(a[i]!=NULL)
{
if(a[i]==’a’||a[i]==’e’||a[i]==’i’||a[i]==’o’||a[i]==’u’)
v++;
else if(a[i]== ‘ ‘)
{
s++;
w++;
}
else
c++;
i++;
}
cout<<“Number of vowels in the string: “<<v<<endl;
cout<<“Number of consonants in the string: “<<c<<endl;
cout<<“Number of spaces in the string: “<<s<<endl;
cout<<“Number of words in the string: “<<w;
}
void main()
{
counts c1;
clrscr();
c1.process();
getch();
}