C++ Program to Remove Vowels from String

Write C++ Program to Remove Vowels from String

// CPP Program to Remove Vowels from String

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

using namespace std;

int main()
{
	char S[100];
	int n;

	cout << "Enter String :--> ";
	gets(S);


	n = strlen(S);
	int i = 0 ,flag = 0;

	while(i < n)
	{
	 	if(S[i] == 'a' || S[i] == 'e' || S[i] == 'i' || S[i] == 'o' || S[i] == 'u')
	 	{
	 		flag = 1;
	 		int j = i;
	 		while(j < n - 1)
	 		{
	 			S[j] = S[j+1];
	 			j++;
			 }
			 n--;
			 i--;
		 }
		 i++;
	}
	S[i] = '\0';
    cout << "New string is :--> " << S;


	return 0;
}

Output:

Enter String :--> Hello and Welcome to CodeCrucks
New string is :--> Hll nd Wlcm t CdCrcks

≪ Previous | Next ≫