Delete Vowels from String in C

Advertisements

Prev Tutorial Next Tutorial

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

delete vowel from string
Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements