1// Delete Vowels from String in C
2/*
3follow below link for best answer:
4-------------------------------------------------
5https://codescracker.com/c/program/c-program-delete-vowels-from-string.htm
6*/
7#include<stdio.h>
8#include<conio.h>
9int main()
10{
11 char str[50];
12 int i=0, j, chk;
13 printf("Enter a String: ");
14 gets(str);
15 while(str[i]!='\0')
16 {
17 chk=0;
18 if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U')
19 {
20 j=i;
21 while(str[j-1]!='\0')
22 {
23 str[j] = str[j+1];
24 j++;
25 }
26 chk = 1;
27 }
28 if(chk==0)
29 i++;
30 }
31 printf("\nString (without vowels): %s", str);
32 getch();
33 return 0;
34}
1#include <stdio.h>
2int check_vowel(char);
3int main()
4{
5char s[100], t[100];
6int c, d = 0;
7gets(s);
8for(c = 0; s[c] != ‘\0’; c++)
9{
10if(check_vowel(s[c]) == 0)
11{
12t[d] = s[c];
13d++;
14}
15}
16t[d] = ‘\0’;
17strcpy(s, t);
18printf(“%s\n”, s);
19return 0;
20}
21int check_vowel(char ch)
22{
23if (ch == ‘a’ || ch == ‘A’ || ch == ‘e’ || ch == ‘E’ || ch == ‘i’ || ch == ‘I’ || ch ==’o’ || ch==’O’ || ch == ‘u’ || ch == ‘U’)
24return 1;
25else
26return 0;
27}
28
1#include<stdio.h>
2void main()
3{
4 char str[100];
5 int i=0, j, chk;
6 int count =0;
7
8 printf("Enter a String: ");
9 gets(str);
10
11 while(str[i]!='\0')
12 {
13 chk=0;
14 if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U')
15 {
16 count ++;
17 j=i;
18 while(str[j-1]!='\0')
19 {
20 str[j] = str[j+1];
21 j++;
22 }
23 chk = 1;
24 }
25 if(chk==0)
26 i++;
27 }
28 printf("\nString without vowels: %s", str);
29 printf("\nNumbers of vowels removed: %d",count);
30}
31