DELETE THE VOWELS FROM A STRING USING C PROGRAM

#include<stdio.h>
int main(){
    char str[20],s[20];
    int i,j=0;
    printf("Enter any string->");
    scanf("%s",str);
    printf("The string is->%s",str);
   for(i=0;i<=strlen(str);i++) {  

        if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u')
                str[i]=' ';
        else 
                s[j++]=str[i];
    } 
    s[j]='\0';
    printf("\nThe string without vowel is->%s",s);
    return 0;
}





Also for the vowel in upper case:



#include<stdio.h>
#include<string.h>
int main(){
    char str[20],s[20];
    int i,j=0;
    printf("Enter any string->");
    scanf("%s",str);
    printf("The string is->%s",str);
   for(i=0;i<=strlen(str);i++) {  
        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')
                str[i]=' ';
        else 
                s[j++]=str[i];
    } 
    s[j]='\0';
    printf("\nThe string without vowel is->%s",s);
    return 0;
}

9 comments:

Anonymous said...

Great and simple to understand program however the if statement needs to have the || i.e. or between the various vowel checks.

Anonymous said...

Thanks alot

www.tipstothepeople.blogspot.com for more

Anonymous said...

if A is in the text then the output will be wrong

Yasin Hasan said...

1st one doesnt work
& 2nd one gives output wrong

Hari Cruz said...

should not be = in condition in the for loop for(i=0;i<=strlen(s);i++)
since a string of length 4 say
home is stored as
0123.so no = needed.

nadiya said...

Nice blog was really feeling good to read it. Thanks for this information.
Spoken English Classes in Chennai
Best Spoken English Class in Chennai
German Classes in Chennai
pearson vue exam centers in chennai
Informatica MDM Training in Chennai
Hadoop Admin Training in Chennai
Spoken English Classes in Tnagar
Spoken English Classes in OMR

harish kalyan said...

Nice Article you have posted here. Thank you for giving this innovative information and
please add more in future.
Hadoop Admin Training Institute in Chennai
Xamarin Training in Chennai
Node JS Training in Chennai
Ionic Training in Chennai 
Blockchain Training in Chennai
content writing training in chennai
spanish language in chennai
Hadoop Admin Training in OMR
Hadoop Admin Training in Porur

Anjali Vinu said...

Fabulous post admin, it was too good and helpful. Waiting for more updates.
Tally course in Chennai
Tally Training in Chennai
Tally institute in Chennai
AngularJS course in Chennai
GST classes in Chennai
PHP course in Chennai
Salesforce course in Chennai
CCNA course in Chennai
Tally Course in Anna Nagar
Tally Course in T Nagar

The India said...

khadi clothes online
buy khadis clothes online
khadi cotton shirt
khadi cotton sadri for men
khadi kurtas for men
khadi online shop
khadi short kurtas for girls