Delete Vowels from String in C
Advertisements
C Program to Delete Vowels from String
To delete vowels from the string in C program, Here we get any string from user and remove all vowels from given string, vowels are (a, A, e, E, i, I, o, O, u, U). Next we start checking for vowel. If any one found of the 10 then place the next character after the found to the back until the last and so on. For example we enter string Harry as a input, after run this code result will be Hrry. You can also see this code in C Programming Language, C++ Program to Delete Vowels from Given String
Delete Vowels from String in C
#include<stdio.h> #include<conio.h> #include<string.h> void main() { char str[20]; int len, i, j; clrscr(); printf("Please Enter any String: "); gets(str); len=strlen(str); for(i=0; i<len; i++) { if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U') { for(j=i; j<len; j++) { str[j]=str[j+1]; } len--; } } printf("After Deleting the vowels, the String is: %s",str); getch(); }
Output
Please Enter any String: Harry After Deleting the vowels, the String is: Hrry
Output
Please Enter any String: Gaurav After Deleting the vowels, the String is: Grv
Output
Google Advertisment