- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove vowels from a String in C++
The following C++ program illustrates how to remove the vowels (a,e, i,u,o) from a given string. In this context, we create a new string and process input string character by character, and if a vowel is found it is excluded in the new string, otherwise the character is added to the new string after the string ends we copy the new string into the original string. The algorithm is as follows;
Algorithm
START Step-1: Input the string Step-3: Check vowel presence, if found return TRUE Step-4: Copy it to another array Step-5: Increment the counter Step-6: Print END
In pursuance of the above algorithm, the following code in c++ language essayed as following;
Example
#include <iostream> #include <string.h> #include <conio.h> #include <cstring> using namespace std; int vowelChk(char); int main(){ char s[50], t[50]; int c, d = 0; cout<<"Enter a string to delete vowels\n"; cin>>s; for(c = 0; s[c] != '\0'; c++) { // check for If not a vowel if(vowelChk(s[c]) == 0){ t[d] = s[c]; d++; } } t[d] = '\0'; strcpy(s, t); cout<<"String after delete vowels:"<<s; return 0; } int vowelChk(char ch){ if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U') return 1; else return 0; }
This C++ program deletes vowels from a string: if the input string is "ajaykumar" then it yields results as "jykmr". Finally, we obtain a string without vowels.
Output
Enter a string to delete vowels ajaykumar String after delete vowels:jykmr
- Related Articles
- Remove Vowels from a String in Python
- How to remove all vowels from textview string in Android?
- How to remove vowels from a string using regular expressions in Java?
- First X vowels from a string in C++
- Reverse Vowels of a string in C++
- Remove Leading Zeros from a String in C#
- C# Program to count vowels in a string
- How to delete the vowels from a given string using C language?
- Remove all duplicates from a given string in C#
- Remove spaces from std::string in C++
- Remove Trailing Zeros from string in C++
- C++ Program to remove spaces from a string?
- Remove a Given Word from a String using C++
- How to remove certain characters from a string in C++?
- Reversing vowels in a string JavaScript

Advertisements