Write a C++ program to delete vowels from a string, where string is entered by the user.

Program Code:
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
char str[50];
int length, i, j;
cout<<"Enter a string to delete vowels from : ";
gets(str);
cout<<endl;
length = strlen(str);
for(i=0; i<length; i++)
{
if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u' || str[i]=='A' || str[i]=='E' || str[i]=='I' || str[i]=='O' || str[i]=='U')
{
for(j=i; j<length; j++)
{
str[j]=str[j+1];
}
length--;
}
}
cout<<"After deleting the vowels, the string will be : "<<str;

return 0;
}

The program output is tested on www.jdoodle.com
Output:
Enter a string to delete vowels from : Mukesh Rajput
After deleting the vowels, the string will be : Mksh Rjpt


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: