1. DOES A DIGIT APPEAR IN AN INTEGER, Write a recursive function appears(n,i) that returns true if the digit i appears in the positive (base 10) integer n, false if it does not in c++. ex.
Enter a positive integer: 54321
Enter a digit: 7
The digit 7 does NOT appear in the integer 54321.
2. IS AN INPUT STRING A PALINDROME? A palindrome is a string in which the letters are the same in both directions, disregarding capitalization and non-letter characters. Write a program that reads a sequence of characters and calls a recursive Boolean function to determine if the letters in the string form a palindrome in c++. example:
csh> pal
Enter a line that might be a palindrome:
Madam I'm Adam.
This string IS a palindrome.
1)
#include <bits/stdc++.h>
using namespace std;
bool appears(int n, int i)
{
// Base case
if(n < 10)
{
return (n == i);
}
// If last digit is i return true
if(n%10 == i)
return true;
// Else recur for n/10
return appears(n/10, i);
}
int main()
{
cout << "3 appears in 1234: " << appears(1234, 3) << " 6 appears in 1234: " << appears(1234, 6);
return 0;
}
Output :

2)
#include <bits/stdc++.h>
using namespace std;
bool palindrome(char str[], int s, int e)
{
// Base case
if(s == e || s + 1 == e)
return true;
// If start is special character then increment s
while((str[s] < 'a' || str[s] > 'z') && (str[s] < 'A' || str[s] > 'Z'))
s++;
// If end is special character then decrement e
while((str[e - 1] < 'a' || str[e - 1] > 'z') && (str[e - 1] < 'A' || str[e - 1] > 'Z'))
e--;
// If start and last are unequal then return false
if(tolower(str[s]) != tolower(str[e - 1]))
return false;
// Otherwise recur
return palindrome(str, s + 1, e - 1);
}
int main()
{
char str[100];
cout << "Enter the string ";
cin >> str;
if(palindrome(str, 0, strlen(str)))
cout << "Palindrome ";
else
cout << "Not Palindrome ";
return 0;
}
Output:

Please upvote if satisfied!! Thanks :)
1. DOES A DIGIT APPEAR IN AN INTEGER, Write a recursive function appears(n,i) that returns true...
I really need help with the code for this, in C++ please, I know there's a similar question but the answer isn't correct :[ A palindrome is a string that reads the same forwards and backwards (ignoring spaces, punctuation, and capitalization). Examples are the familiar ``If I had a hi-fi,'' the grander ``A man, a plan, a canal, Panama,'' and ``Some men interpret nine memos.'' So the goal: Design, implement, document, and test a program that reads a line of...
Write a recursive function Programming: to_number that forms the integer sum of all digit characters in a string. For example, the result of to_number("3ac4") would be 7. C++ i know this has been answered before but I keep getting 0 when I enter a string.
Write a recursive function called sumover that has one argument n, which is an unsigned integer. The function returns a double value, which is the sum of the reciprocals of the first n positive integers. (The reciprocal of x is the fraction 1/x.) For example, sumover(1) returns 1.0 (which is 1/1); sumover(2) returns 1.5 (which is 1/1 + 1/2); sumover(3) returns approximately 1.833 (which is 1/1 + 1/2 + 1/3). Define sumover(0) to be zero. Do not use any local...
Write a recursive function named arithmeticSum that takes a positive integer parameter n and returns the sum of the integer numbers from 1 to n Please write in C++
write a recursive function that returns true if the digits of a positive integer are in increasing order ; otherwise, the function returns false. Also write a program to test your function.
Please i need programs in C 32) Write a function that, given a string, a width, and an empty string for output, centers the string in the output, centers the string in the output area. The function is to return 1 if the formating is successful and 0 if any errors, such as string length greater than width, are formed. 35) Write a function called newStrCmp that does the same job as strcmp. The declaration for your functions is to...
Using C++
Question#1: isPalíndrome Write the following function: bool isPalindrome(int) takes an integer and returns true if that integer is palindrome, otherwise it returns false. The function also prints the digits of the integer in reverse order in which they were found. Write a main) function that reads an integer, calls the function is whether the integer is a palindrome or not. Palindrome), and prints Sample input/output: nter an integer: 23434 nter an integer 23432 3434 is not a palindrome...
I need help programming this program in C. 1.) Write a program that reads a message, then checks whether it's a palindrome (the letters in the message are the same from left to right as from right to left), example is shown below: Enter a message: He lived as a devil, eh? Palindrome Enter a message: Madam, I am Adam. Not a Palindrome 2.) Ignore all characters that aren't letters. Use integer variables to keep track of positions in the...
Use C++ to write a recursive function that takes in a non-negative integer and returns the count of the occurrences of 7 as a digit, so for example 717 yields 2. Note: Even though it would be easy to solve this problem iteratively, the goal is to get some practice solving problems recursively.
Write c++ recursive function 3. A function that takes an integer, and returns the product of the digits, so the input 1989 would return 1∗9∗8∗9 = 648 4. A function that does the above repeatedly, taking a number and computing the product of it’s digits until you get a single digit number: so on input 1989 it would go 1989→648→192→18→8 and return 8. (Note, you can use the previous functions if you want.