removing vowels from a string code example
Example 1: Java program to delete vowels in a given string
import java.util.*;
public class RemoveVowelsInString
{
public static void main(String[] args)
{
String str = "Deekshit Prasad";
System.out.println("Given string: " + str);
str = str.replaceAll("[AaEeIiOoUu]", "");
System.out.println("After deleting vowels in given a string: " + str);
}
}
Example 2: remove vowels in string
#include <stdio.h>
int check_vowel(char);
int main()
{
char s[100], t[100];
int c, d = 0;
gets(s);
for(c = 0; s[c] != ‘\0’; c++)
{
if(check_vowel(s[c]) == 0)
{
t[d] = s[c];
d++;
}
}
t[d] = ‘\0’;
strcpy(s, t);
printf(“%s\n”, s);
return 0;
}
int check_vowel(char ch)
{
if (ch == ‘a’ || ch == ‘A’ || ch == ‘e’ || ch == ‘E’ || ch == ‘i’ || ch == ‘I’ || ch ==’o’ || ch==’O’ || ch == ‘u’ || ch == ‘U’)
return 1;
else
return 0;
}