#include <stdio.h>
#include <string.h>
#include <conio.h>
int checkcons(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(checkcons(input[i]) == 0) //check whether function returns 0
{
output[j] = input[i]; //if it is a vowel shift it in output array
j++; //increment output index
}
}
output[j] = '\0';
printf("\n String after deleting consonants :%s\n", output);
getch();
return 0;
}
int checkcons(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 0; // returns vowel
default:
return 1; //returns consonants
}
}
C program to delete consonants from string
#include <string.h>
#include <conio.h>
int checkcons(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(checkcons(input[i]) == 0) //check whether function returns 0
{
output[j] = input[i]; //if it is a vowel shift it in output array
j++; //increment output index
}
}
output[j] = '\0';
printf("\n String after deleting consonants :%s\n", output);
getch();
return 0;
}
int checkcons(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 0; // returns vowel
default:
return 1; //returns consonants
}
}