Delete Vowels from Given String in C++

Google Advertisements

Prev Tutorial Next Tutorial

C++ Program to Delete Vowels from Given String

To delete all the vowels (i.e., a, A, e, E, i, I, o, O, u, U) from the string in C++ program. In case of english alphabet their are 5 lower case letter and 5 captipal letter, in this programming code we remove all small as well as capital letter from given string. You can also see this code in C Programming Language, C Program to Delete Vowels from Given String

C++ Program to Delete Vowels from Given String

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
char str[20];
int len, i, j;
clrscr();
cout<<"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--;
}
}
cout<<"After Deleting the vowels, the String is:"<<str;
getch();
}

Output

Please Enter any String: Hitesh Kumar
After Deleting the vowels, the String is: Htsh Kmr

Output

Please Enter any String: Reetu
After Deleting the vowels, the String is: Rt

Output

Delete Vowels from Given String in C++
Prev Tutorial Next Tutorial

Download Projects

Adsense Advertisements
Free Classified Site – Bedpage

Yahoo Ads Advertisements