Write a program in C or C++ to delete all vowels from a string using function.

Question: Write a program in C or C++  to delete all vowels from a string with the help of a function.

Source Code:

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
char print(char str[]) //function to delete vowels
{

int i,l;
l=strlen(str);
for(i=0;str[i]!=NULL;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(int j=i;j<l;j++)
{
str[j]=str[j+1];
}
  }

}
cout<<endl<<endl<<"New String : "<<str;
}

void main()
{
clrscr();
char str[100];
cout<<"Enter String : ";
gets(str);
print(str); //calling PRINT function
getch();
}

Output

Comments