### Recursive function for "vowels",Recursive function for "sum of array"

Hello,

Will you please write a c++ program which includes all functions,

1) Recursive function for "vowels", that returns number of vowels in string.

2) Recursive function for "sum of array"

3) Program that uses a recursive function to check whether a string is Palindrome

4) Program that uses recursive function to print string backward

5) write a Recursive function for "backword number"(i.e: reversedigits, that takes an integer as a parameter and returns the number with digits)

6) Recursive function for "power"

Please let me know if i am not clear.

Thank you so much

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142`` ``````#include #include #include using std::cout; using std::cin; using std::endl; using std::string; struct Words { int CountVowels(string, int); public: Words(string); bool isPal(string, int); void Print(); string Skippy; int numVowel; int length; ~Words(); }; Words::Words (string m) { Skippy = m; length = 0; numVowel = CountVowels(Skippy, 0); } int Words::CountVowels(string myWord, int startindex) { length++; int pandi; std::transform(myWord.begin(), myWord.end(), myWord.begin(), tolower); if (myWord[startindex]) { if (myWord[startindex] != 'a' && myWord[startindex] != 'e' && myWord[startindex] != 'i' && myWord[startindex] != 'o' && myWord[startindex] != 'u') pandi = 0; else pandi = 1; return pandi + CountVowels(myWord, startindex+1); } return 0; } bool Words::isPal(string myWord, int size) { int r = myWord.size() - size; int t = size - 1; std::transform(myWord.begin(), myWord.end(), myWord.begin(), tolower); if (size == r || r == t) return true; //size = r is true when it is an even size string and //the 2 middle characters have been checked //r = t is true when it is an odd size string and the //two chars on either side of the middle char have been checked if ((myWord[r]) != (myWord[t])) return false; return isPal(myWord, --size); } void Words::Print() { cout << Skippy[--length]; if (length == 0) { cout < 0) { int t = num/10; int k = t * 10; cout << (num - k); num = t; BackwardNum(num, init = false); } else { if (num > 0 || init) cout << num; cout << endl; } } int main() { string test; long Val; cout << "\nEnter a string: "; getline(cin, test); Words myTestWord(test); cout << "The string " << myTestWord.Skippy << " is " << (myTestWord.isPal(myTestWord.Skippy, myTestWord.Skippy.size()) ? "palindrome\n" : "not palindrome\n"); cout << "The number of vowels in the string is " << myTestWord.numVowel << endl; cout <<"String backwards is "; myTestWord.Print(); cout << "\nEnter a number: "; cin >> Val; cout << Val << " to the power of 2 is " << pows_n(Val, 2); cout << "\nNumber backwards is "; BackwardNum(Val); return 0; }``````

 ```Enter a string: What is yours sruoy si tAHW The string What is yours sruoy si tAHW is palindrome The number of vowels in the string is 8 String backwards is WHAt is yours sruoy si tahW Enter a number: 2563 2563 to the power of 2 is 6568969 Number backwards is 3652 tilde delete```
Last edited on
 @Smac89

Your code is invalid. For example function BackwardNum does not return a reverse number. And I think that it shall be declared as

long BackwardNum( long );

 ``1234567`` ``````long BackwardNum(long num) { int t = log10(num); if (t == 0) return num; return (((num%10) * pows_n(10, t)) + BackwardNum(num/10)); }``````