"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Thursday, January 7, 2010

count the number of words starting with vowel

/*  Input ::   I am Fine.
     Output :: 2         */



#include<iostream.h>
#include<conio.h>
#include<string.h>

void main()
{
int vc=0;
char sen[25], ch;

cout<< "\n Type A Sentance:";
cin.getline(sen,25);

for(int i =0; sen[i]!='\0'; i++)
{
if(sen[i]==' ')
{
while(sen[i] = =  ' ')  /* remove multiple space */
i++;

ch = toupper(sen[i]);

switch(ch)
{
case 'A':
case 'E':
case 'O':
case 'I':
case 'U':
                  vc++;
}
 }
}
cout<<"\n  The total number of words starting with a vowel is : "<< vc;

getch();
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.