Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstring>
- using namespace std;
- int main()
- {
- string str;
- int vc[5] = {0,0,0,0,0} ; //vowel counter
- cout<<"Enter string: ";
- getline(cin,str);
- cout<<"Input size: "<<str.size()<<endl;
- const char * tstr = str.c_str();
- char rstr[str.size()],cstr[str.size()];
- int j = 0;
- for(int i = str.size()-1 ; i >= 0 ; i--)
- {
- rstr[i] = tstr[j++];
- switch(rstr[i])
- {
- case 'A':
- case 'a':
- vc[0]++;
- break;
- case 'E':
- case 'e':
- vc[1]++;
- break;
- case 'I':
- case 'i':
- vc[2]++;
- break;
- case 'O':
- case 'o':
- vc[3]++;
- break;
- case 'U':
- case 'u':
- vc[4]++;
- break;
- }
- }
- cout<<"#Vowel in input string: A="<<vc[0]<<", E="<<vc[1]<<", I="<<vc[2]<<", O="<<vc[3]<<", U="<<vc[4]<<endl;
- cout<<"Reverse string: "<<rstr<<endl;
- cout<<"Concatenated string : "<<strcat(rstr,strcpy(cstr,tstr));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement