#include <stdio.h>
#include <string.h>
#include <conio.h>
int checkvowel(char); //function declaration
int main()
{
char input[50], output[50];
int i, j = 0;
printf("Enter a string\n");
gets(input);
for(i = 0; input[i] != '\0'; i++) //for whole of the input string
{
if(checkvowel(input[i]) == 0) //check whether function returns 0
{
output[j] = input[i]; //if it is a consonant shift it in output array
j++; //increment output index
}
}
output[j] = '\0';
printf("\n String after deleting vowels: %s\n", output);
getch();
return 0;
}
int checkvowel(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; //return 1 if is vowel
default:
return 0; // return 0 if it is consonant
}
}
Output:
C program to delete vowels from a string
#include <string.h>
#include <conio.h>
int checkvowel(char); //function declaration
int main()
{
char input[50], output[50];
int i, j = 0;
printf("Enter a string\n");
gets(input);
for(i = 0; input[i] != '\0'; i++) //for whole of the input string
{
if(checkvowel(input[i]) == 0) //check whether function returns 0
{
output[j] = input[i]; //if it is a consonant shift it in output array
j++; //increment output index
}
}
output[j] = '\0';
printf("\n String after deleting vowels: %s\n", output);
getch();
return 0;
}
int checkvowel(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; //return 1 if is vowel
default:
return 0; // return 0 if it is consonant
}
}
Output: