Search This Blog

Sunday, 16 March 2014

delete consonant from any string


/*
   Suppose we have a string as
    ANIMAL  then this program will do and present the result as  A _ I _ A _
 */


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

void main()
{
  char str[20];
  int len=0,i;
  cout<<"Enter any string :";
  cin.get(str,20);
  for(i=0;str[i]!='\0';i++)
    len++;
  for(i=0;i<len;i++)
  {
    if(str[i]=='A'||str[i]=='a'||str[i]=='e'||str[i]=='E'||str[i]=='i'||
    str[i]=='I'|str[i]=='o'||str[i]=='O'||str[i]=='u'||str[i]=='U')
      cout<<str[i];
    else if(str[i]==' ')
      cout<<"  ";
    else
       cout<<"_";
  }
  getch();
}

Output


No comments:

Popular Posts