C Program to Remove all Vowels From String

Can I teach the possibility to run the C Program to Remove all Vowels From String using this article? Without wasting our time, Move on to the article directly.

C Program to Remove all Vowels From String

C Program to Remove all Vowels From String

Source Code

  #include <stdio.h>
#include <string.h>
int check_vowel(char);

int main()
{
  char s[100], t[100];
  int c, d = 0;

  printf("Enter a string to delete vowels:");
  gets(s);

  for (c = 0; s[c] != '\0'; c++) {
    if (check_vowel(s[c]) == 0) {     // If not a vowel
      t[d] = s[c];
      d++;
   }
  }

  t[d] = '\0';

  strcpy(s, t);  // We are changing initial string. This is optional.

  printf("String after deleting vowels: %s", s);

  return 0;
}

int check_vowel(char t)
{
  if (t == 'a' || t == 'A' || t == 'e' || t == 'E' || t == 'i' || t == 'I' || t =='o' || t=='O' || t == 'u' || t == 'U')
    return 1;

  return 0;
}

Output

The reference output will be shown below.

C Program to Remove all Vowels From String
C:\Users\Ranjith\Music\CPP>cd "c:\Users\Ranjith\Music\CPP\" && gcc app.c -o app && "c:\Users\Ranjith\Music\CPP\"app
Enter a string to delete vowels:apple
String after deleting vowels: ppl

Video Tutorial

Final Thoughts

I hope this article helps you to execute the C Program to Remove all Vowels From String successfully. Please ask your doubts regarding the topic via the comment section. Share this article to other C/C++ learners via social media.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment