Write C++ program that reads the string and prints the vowels and their number. The program takes a string from the user and stores it in a character array and store all its vowels in another array of type char and counts the number of vowels found.
1
Expert's answer
2014-12-05T01:24:03-0500
#include<iostream.h> #include<string.h> #define MAX 1000 int main() { char *s=new char[MAX], *vowelsS=newchar[MAX]; char vowel[13]; strcpy(vowel,"EeUuIiOoAa"); inti,j, n=0; cout<<"Input the string:"; cin.getline(s,MAX); for(i=0;i<strlen(s);i++) for(j=0;j<strlen(vowel);j++) if(s[i]==vowel[j]) { vowelsS[n]=vowel[j]; n++; break; } vowelsS[n]='\0'; cout<<"vowels of string:"<<vowelsS<<", total count: "<<n; return 0; }
Comments
Leave a comment