Program to delete vowels from a given string

Written by

Juhi Kamdar

Delete vowels

The English alphabets {a,e,i,o,u} are called as vowels. Here, we are going to delete all the vowels found in the string given by the user.


We will traverse each character, if it is a consonant, then we will add it to a new string, else ignore it. Then we’ll copy the new string to the original string.


  1. Input a string.
  2. Run a for loop to traverse the given string.
  3. Check each character is a vowel or not, using the function.
  4. Copy the contents of the new string in the old string.
  5. Print the modified string


#include <iostream>
#include <cstring>
using namespace std;
int vowel(char c)
	if (c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c =='o' || c=='O' || c == 'u' || c == 'U')
		return 1;   // a vowel
		return 0;   // not a vowel
int main()
	string str,newstr;
	cout<<"Enter a string: ";
	int len=str.length();
	int j=0;
	for(int i = 0; i<len; i++)
		if(vowel(str[i]) == 0)
			newstr[j] = str[i];    //newstr is string without vowels
	newstr[j] = '\0';  //terminate the string
	strcpy(str, newstr);    //copying the new string,  
	cout<<"Modified String:"<<str;
	return 0;


Enter a string: Vowels will be deleted

Modified string: Vwls wll b dltd

Program to delete vowels from a given string