C Programming Examples Tutorial Index

C String Programs

There are five letters A, E, I, O, and U called vowels in English. Except for these five vowels, all other letters are called consonants.



This C example program removes vowels letters from a user-entered string. It checks the conditions in a user-defined function inside the loop and prints the output to the screen.

Example C Program:
#include <stdio.h>
#include <string.h>

int vowel_check(char); /* Define function prototype. */

int main() {
  /* Variable Declaration and Initialization. */
  char inputs[100], output[100];
  int i, d = 0;
  
  /* taking user input */
  printf("Enter some text:\n");
  gets(inputs);

  /* checking and removing the vowels letters */
  for (i = 0; inputs[i] != '\0'; i++) {
    if (vowel_check(inputs[i]) == 0) {
      /* not a vowel  */
      output[d] = inputs[i];
      d++;
    }
  }
  output[d] = '\0';
  strcpy(inputs, output);
  printf("The text after deleting Vowels letters: %s\n", inputs);
  return 0;
}

/* Function Definition - User Defined Function */
int vowel_check(char l) {
  if (l == 'a' || l == 'A' || l == 'e' || l == 'E' || l == 'i' || l == 'I' ||
    l == 'o' || l == 'O' || l == 'u' || l == 'U')
    return 1;
  return 0;
}

Program Output:

Enter some text:
W3schools.in
The text after deleting Vowels letters: W3schls.n


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram