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

C Program to Find no of Vowels Consonants and Space from a String

C Program to Find no of Vowels , Consonants and Space from a String. Compiled in DEV C++

 

#include<stdio.h>
#include<string.h>
#include<conio.h>
void Find_Vowels(char *,int *,int *,int *);
main()
{
        char a[30];
        int vowel,Consonants,Space;
        printf("\n Program to Find no of Vowels , Consonants and Space from a String \n");
        printf("\n-----------------------------------------------------------------------\n\n\n");
        printf("Enter Text : ");                                                   
        gets(a);
        
        strlwr(a);
        
        Find_Vowels(a,&vowel,&Consonants,&Space);
        
        printf("\nNo of Vowels : %d ",vowel);
        
        printf("\nNo of Consonants : %d ",Consonants);
        
        printf("\nNo of Space : %d ",Space);
        
        getch();
      
      
}

 void Find_Vowels(char *a,int *vowels,int *consonants,int *space)
     {
        int length=0;
        int v=0,c=0,s=0;
        
        while(*a!='\0')
        {
          if(*a==' ')
          {
              s++;  
          }
          
          if((*a=='a')||(*a=='e')||(*a=='i')||(*a=='o')||(*a=='e')||(*a=='u'))
          {
              v++;                                                           
                                                                                
          }
            
          length++;
          a++;              
        }    
        
        c=length-(v+s);
        
        *vowels=v;
        *consonants=c;
        *space=s;
        
          
     }

 

Output

vowelwithspace