Program to Remove vowels from a string

Program to Remove vowels from a string

10 May 2023

10 May 2023

Write a Program to Remove vowels from a string



If you are from 2023 batch student, Join our Telegram group for placement preparation and coming placement drive updates : https://t.me/talentbattle2023

Description about the Program to Remove vowels from a string

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 to Remove vowels from a string

#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 to Remove vowels from a string

#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 Program to Remove vowels from a string

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 Program to Remove vowels from a string

import re

str1 = input("Enter a string: ")

print(re.sub("[aeiouAEIOU]","",str1))


If you are from 2023 batch student, Join our Telegram group for placement preparation and coming placement drive updates : https://t.me/talentbattle2023


Related Articles

Ask Us Anything !