Saturday, August 9, 2014

Program to remove the vowels from a string.

Simple C program to remove the vowels from a string. If you have any doubts, please let me know.

#include<stdio.h> #include<string.h> main() { char s[200]; int i=0,j=0,n; printf("\n\n Enter the sentence : "); gets(s); n=strlen(s); while(i<n) { if((s[i]=='a')||(s[i]=='e')||(s[i]=='i')||(s[i]=='o')||(s[i]=='u')||(s[i]=='A')||(s[i]=='E')||(s[i]=='I')||(s[i]=='O')||(s[i]=='U')||(s[i]==' ')) { for(j=i;j<n;j++) { s[j]=s[j+1]; } n--; } else i++; } printf("\n\n New sentence : "); for(i=0;i<n;i++) printf("%c",s[i]); printf("\n\n"); }

No comments:

Post a Comment