C Program to remove vowels from string: Removing all the vowels present in the string and printing the string without any vowels in a string.

Example:-
String = “Vowels”
Removing vowels from string
String = “Vwls”

Algorithm to remove vowels from string

  1. Take a string input
  2. Traverse string from start to end
    If character != vowel
    new string= character
    else
    Skip character

C Program to Remove Vowels from 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 to delete vowels\n");
gets(s);

for(i = 0; s[i] != '
#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 to delete vowels\n");
gets(s);

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

t[j] = '\0';

strcpy(s, t); //We are changing initial string

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

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':
return 1;
default:
return 0;
}
}
'; i++) { if(check_vowel(s[i]) == 0) { //not a vowel t[j] = s[i]; j++; } } t[j] = '
#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 to delete vowels\n");
gets(s);

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

t[j] = '\0';

strcpy(s, t); //We are changing initial string

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

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':
return 1;
default:
return 0;
}
}
'; strcpy(s, t); //We are changing initial string printf("String after deleting vowels: %s\n", s); 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': return 1; default: return 0; } }

Output :

C Program to Remove Vowels from String

Write A Comment