-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeleteVowel.cpp
56 lines (48 loc) · 1.12 KB
/
DeleteVowel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
C++ program to remove or delete vowels from a string, if the input string is
"Sanjeev" then output will be "Snjv". In the program we create a new string
and process entered string character by character, and if a vowel is found
it is not added to new string otherwise the character is added to new string,
after the string ends we copy the new string into original string.
Finally we obtain a string without any vowels.
*/
#include <iostream.h>
#include<conio.h>
#include <string.h>
int check_vowel(char);
int main()
{
char s[100], t[100];
int i, j = 0;
cout<<"Enter a string to delete vowels";
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);
cout<<"String after deleting vowels: "<<s;
getch();
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;
}
}