Answer to Question #267594 in C++ for Yasir

Question #267594

Write a program to create a dynamic array of user defined size. Array should be character type. Write a function RemoveVowels() that should remove all the vowels in the array. All array operations should be done using pointers.

1
Expert's answer
2021-11-17T17:35:43-0500


SOLUTION CODE FOR THE ABOVE QUESTION


#include<iostream>
#include <bits/stdc++.h>
using namespace std;


    
void RemoveVowels(char str[], int n)
{
    
 vector<char> vowels = {'a', 'e', 'i', 'o', 'u','A', 'E', 'I', 'O', 'U'};
     
    for (int i = 0; i < n(); i++)
    {
        if (find(vowels.begin(), vowels.end(),
                      str[i]) != vowels.end())
        {
            str[i] = str.replace(i, 1, "");
            i -= 1;
        }
    }
    


}




int main(){
	cout<<"Enter the size of the array:\n";
	int n;
	cin>>n;
	char letters[n];
	cout<<"Enter the string\n";
	cin>>letters;
	RemoveVowels(letters,n);
	cout<<letters<<endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS