Description
Get a string as the input from the user and then remove all the vowel letters from the string and give the output.
Input
remove
Output
rmv
C Program
#include <stdio.h>
#include <string.h>
int check_vowel(char);
int main()
{
char s[100], t[100];
int i, j = 0;
printf("Enter a string: ");
scanf("%[^\n]s",s);
for(i = 0; s[i] != '\0'; i++)
{
if(check_vowel(s[i]) == 0)
{
t[j] = s[i];
j++;
}
}
t[j] = '\0';
printf("%s\n", t);
return 0;
}
int check_vowel(char c)
{
switch(c)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
case ' ':
return 1;
default:
return 0;
}
}
C++ Program
#include <iostream>
#include <string.h>
using namespace std;
int check_vowel(char);
int main()
{
char s[100], t[100];
int i, j = 0;
cout<<"Enter a string: ";
cin>>s;
for(i = 0; s[i] != '\0'; i++)
{
if(check_vowel(s[i]) == 0)
{
t[j] = s[i];
j++;
}
}
t[j] = '\0';
cout<<t;
return 0;
}
int check_vowel(char c)
{
switch(c)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
case ' ':
return 1;
default:
return 0;
}
}
Java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = sc.nextLine();
String s1 = "";
s1 = str.replaceAll("[aeiou]", "");
System.out.println(s1);
}
}
Python
import re
str1 = input("Enter a string: ")
print(re.sub("[aeiouAEIOU]","",str1))