Thursday 20 September 2012

String021

Input a name or a sentence and find the vowel on that name.

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main ( )
{
         char        nm1[80], nm2[80], nm3[80], c;
         int           ln,  j, i = 0, k = 0;
         clrscr ( );
               
         printf("\n\n\n\t Enter a sentence or a name......:"); gets (nm1);
         ln = strlen (nm1);
                     
         for ( j = 0; j < ln; j++ )
         {           
                     c = nm1[j];
                     if ( c != ' ' )
                     {                         
                              if ( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'
                                    || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' )
                                                        nm2[i++] = nm1[ j];
                              else                            
                                                        nm3[k++] = nm1[ j];
                     }
         }
         nm2[i] = '\0';
         nm3[k] = '\0';
                                    
         printf("\n\n\n\t The vowel in a name or a sentence ....: %s",nm2);
         printf("\n\n\n\t The consonant in a name or a sentence ....: %s",nm3);
         getch ( );
}
Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...