C Program to Find two Successive Vowels from a String

C Program to Find  two Successive Vowels from a String.Compiled in DEV C++

 

#include<stdio.h>
#include<string.h>
#include<conio.h>
int FindSuccessiveVowel(char [],char []);
int CheckIfVowel(char );
int string_length(char *);
main()
{
        char a[30],b[30];
        int count;
        printf("\n Program to Find two Successive Vowels from a String \n");
        printf("\n-----------------------------------------------------------\n\n\n");
        printf("Enter Text : ");
        gets(a);

        strlwr(a);

        count=FindSuccessiveVowel(a,b);

        printf("\n\nNo of Successive Vowels : %d ",count);

        printf("\n\n\nSuccessive Vowels : %s",b);

        getch();

}

int FindSuccessiveVowel(char source[],char target[])
{
    char *p;
    int i,k=0,count=0;

    for(i=0;i<string_length(source)-1;i++)
    {
       p=&source[i];

       if((CheckIfVowel(*p)==1)&&(CheckIfVowel(*(p+1))==1))
       {
           count++;
           target[k]=*p;
           k++;
           target[k]=*(p+1);
           k++;
           target[k]=' ';
           k++;
       }

     } 

      target[k]='\0';

      return count;

}                           

int CheckIfVowel(char a)
{
    if((a=='a')||(a=='e')||(a=='i')||(a=='o')||(a=='e')||(a=='u'))
          {
              return 1;                                                           

          }

    return 0;

}        

int string_length(char *a)
     {
          int count=0;
            while(*a!='\0')
            {
                  count++;
                   a++;
            }

        return count;

     }

 

Output

successive

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s