Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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#include #include #include using namespace std; int vowelChk(char); int main(){ char s[50], t[50]; int c, d = 0; cout>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 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
Advertisements
