Member Avatar for nssrsaran

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"

Thank you so much

Recommended Answers

All 3 Replies

I think you've come to the wrong place. This is a place to help people with specific problems, mostly in code that they've already written. You need a site where you can hire a professional to do this. This is one such site. Unless of course you do have some code that you need help with, then by all means show us the code and describe the problem and we'll be more than happy to help you.

No, and that is with a capital "N". Now if you want to contract someone to do it there is a section to do that.

#include<iostream>

using namespace std;

int CountVowels (const string text)
{
    const string VOWELS = "aeiou";

    if (text.length() == 0)
    {
        return 0;
    }
    else
    {
        if (VOWELS.find(tolower(text[0])) != string::npos)
        {
            return CountVowels (text.substr(1)) + 1;
        }
        else
        {
            return CountVowels (text.substr(1));
        }
    }
}


int ArraySum (const int array[], const int size)
{
    if (size == 0)
    {
        return 0;
    }
    else
    {
        return array[0] + ArraySum(array + 1, size - 1);
    }
}


bool IsPalindrome (const string text)
{
    if (text.length() <= 1)
    {
        return true;
    }
    else if (!isalpha(text[0]))
    {
        return IsPalindrome(text.substr(1));
    }
    else if (!isalpha(text[text.length() - 1]))
    {
        return IsPalindrome(text.substr(0, text.length() - 1));
    }
    else
    {
        return (tolower(text[0]) == tolower(text[text.length() - 1])) && IsPalindrome(text.substr(1, text.length() - 2));
    }
}


void PrintBackwards (const string text)
{
    if (text.length() > 0)
    {
        cout << text[text.length() - 1];
        PrintBackwards(text.substr(0, text.length() - 1));
    }
}


int ReverseDigits (const int number, const int addition = 0)
{
    if (number < 10)
    {
        return (addition * 10) + (number % 10);
    }
    else
    {
        return ReverseDigits(number / 10, (addition * 10) + (number % 10));
    }
}


int Power (const int number, const int power)
{
    if (power <= 0)
    {
        return 1;
    }
    else
    {
        return number * Power(number, power - 1);
    }
}


int main()
{

    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.