WAP TO COUNT NO. OF WORDS AND VOWELS IN A STRING

 

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
Void main()
{
     char str[20];
     int count=0,words=0;
     clrscr();
     cout<<”Enter the string:”;
     gets(str);
     for(int i=0;str[i]!=’\0’;i++)
  {
                    if(str[i]==’a’||str[i]==’e’||str[i]==’i’||str[i]==’o’||str[i]==’u’)
    {
         count++;
    }
    if(str[i]==’  ‘)
    {
         words=words+1;
    }
    cout<<”No. of vowels are:”<<count<<”\n”;
    cout<<”No. of words are:”<<words+1;
    getch();

}

Comments

Popular Posts