+ 3
Count vowel using pointer arithmetic
can we find number of vowels present in a given character array using pointer arithmetic
1 ответ
+ 6
well I don't know too much about pointer algorithm but maybe this is how we do it :
int main() {
char *word = new char[250];
char *vov = {'a','e','i','o','u'};
cin.getline(word,250);
int i,j,num_vov=0;
for(i=0;i<strlen(word);i++) {
for(j=0;j<5;j++) {
if(word[i]==vov[j]) {
num_vov+=1;
}
else { num_vov+=0 };
}
}
cout<<"\n Number of vowels = "<<num_vov;
return 0;
}