#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;
}
5 comments:
Great and simple to understand program however the if statement needs to have the || i.e. or between the various vowel checks.
Thanks alot
www.tipstothepeople.blogspot.com for more
if A is in the text then the output will be wrong
1st one doesnt work
& 2nd one gives output wrong
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.
Post a Comment