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
Post A Comment:
0 comments: