Tuesday, 5 December 2017

C program to remove consonants from the string



QUESTION - 2

 Write a C program to remove consonants from the string.

#include<stdio.h>

int main()
{
    char a[20];
    int i=0;
    printf("Enter a lowercase String: ");
    gets(a);
    while(a[i]!='\0')
    {
        if(a[i]>95 && a[i]<122)
        {
            if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'|| a[i]=='u')
                printf("%c",a[i]);


        }

        else
            printf("%c",a[i]); // to print spaces in between words of string
        i++;
    }
    return 0;

}

Output:
Enter a lowercase String: hello world ↵
                                                   eo o

No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...